public static Enum[] EnumToArray(Enum enumeration)
{
//get the enumeration type
var et = enumeration.GetType();
//get the public static fields (members of the enum)
var fi = et.GetFields(BindingFlags.Static | BindingFlags.Public);
//create a new enum array
var values = new Enum[fi.Length];
//populate with the values
for (var iEnum = 0; iEnum < fi.Length; iEnum++)
{
values[iEnum] = (Enum)fi[iEnum].GetValue(enumeration);
}
//return the array
return values;
}