Convert an enum to a List

Sometimes you need a function to convert a enum to a string array.

There is already a class (Enum) which helps us to do so

string[] abc = Enum.GetNames(...);
Advertisements
  1. Hi there

    Do not expose generic list class to public APIs, see:
    http://www.google.ch/search?hl=de&source=hp&q=do+not+expose+generic+lists&meta=&aq=1&oq=do+not+expose+

    You don`t know the Enum class in the FCL?
    There are several methods like Enum.GetValues(), Enum.GetNames and Enum.Parse().

    Look out 🙂

    Bye, Peter

      • michlG
      • August 27th, 2009

      Hello Peter,

      thank you for your reply. I have not seen this before so I used this self made method 🙂
      But you are right because it is much better to use the methods of the Enum class.

      I will modify my post and show the solution like it should be 🙂

      Thank you
      Bye, Michael

  1. No trackbacks yet.

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

%d bloggers like this: