
This is a sniet I use to retrieve the values form an enum, and populating a Collection with the returned values
Instructions: Pass the snippet the enum you want the value from and watch it work.
Make sure you have using System.Collections.ObjectModel; in your class
public Collection<String> LoadCsvTypes(Type _enum)
{
Collection<String> str = new Collection<string>();
//get the names from the enumeration
string[] names = System.Enum.GetNames(_enum);
//Now we loop through all the names in the enum list
for (int i = 0; i <= names.Length - 1; i++)
{
str.Add(names[i]);
}
return str;
}-Offline- |