xxxxxxxxxx
// Assume we have an enum called "Colors"
public enum Colors
{
Red,
Green,
Blue
}
// Retrieving all the values of the "Colors" enum
var enumValues = Enum.GetValues(typeof(Colors));
// Converting the enum values to an array
var valuesArray = (Colors[]) enumValues;
// Printing all the values
foreach (var value in valuesArray)
{
Console.WriteLine(value);
}