Home
Manage Your Code
Snippet: Enumerate an Enumeration (C#)
Title: Enumerate an Enumeration Language: C#
Description: Shows how to enumerate all types within an enumeration. Useful for populating all Enum values into a combobox or listbox. Views: 686
Author: Randall Sexton Date Added: 3/19/2007
Copy Code  
1foreach (EnumerationName oType in Enum.GetValues(typeof(EnumerationName )))
2{
3	//Do something with oType

4}
Usage
EnumerationName --> the actual name of the Enum whose values you want
Notes
VB version is: For Each oType As EnumerationName in [Enum].GetValues(GetType(EnumerationName)) Next