How to return a string array from an enum in C#?

So I have a enum and I want to pass it to a ComboBox, so I need it to be an array of strings.

Well, this was much more simple than I thought:

public static string[] EnumToStringArray(Type inType)
	return Enum.GetNames(typeof(inType));

I found a few sites that were taking some much more complex routes, maybe they didn’t know about this feature.


  1. Dhinesh babu says:

    I unable to find the method Enum.GetNames. I can see only GetName method. It returns only string instead of String[]. Do you have any inputs for me ?

Leave a Reply

How to post code in comments?