I have read documentation that states that ‘given the type of the enum, the GetValues() method of System.Enum will return an array of the given enum\'s base type’ ie int, by
Personally I've created a separate method in my Utils project, which I include in my other projects. Here's the code I use:
public static class EnumUtil
{
public static IEnumerable GetAllValues()
where TEnum : struct, IConvertible, IComparable, IFormattable
{
return Enum.GetValues(typeof(TEnum)).Cast();
}
}
And I call it like this:
var enumValues = EnumUtil.GetAllValues();