October 15, 2009

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

Filed under: C# (C-Sharp) — J. Abram barneck @ 5:54 am

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. 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 ?

    Comment by Dhinesh babu — July 27, 2010 @ 11:48 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: