BLOG.CSHARPHELPER.COM: Easily list the values defined by an enumerated type in C#
Easily list the values defined by an enumerated type in C#
The example Bind arrays and lists to ListBoxes to easily display their items in C# shows an easy way to display the values defined by an array or list.
The example Use reflection to list the values defined by an enum in C# shows one way to list the values defined by an enumerated type. That method is flexible but somewhat awkward.
This example uses the first technique to display a list of enumerated values. Instead of using reflection, this example uses the Enum class's GetValues method to get the array of enumerated values. This lets the program display the list with this single line of code:
Comments