How can you enumerate an enum
in C#?
E.g. the following code does not compile:
public enum Suit
{
I tried many ways and got the result from this code:
For getting a list of int from an enum, use the following. It works!
List listEnumValues = new List();
YourEnumType[] myEnumMembers = (YourEnumType[])Enum.GetValues(typeof(YourEnumType));
foreach ( YourEnumType enumMember in myEnumMembers)
{
listEnumValues.Add(enumMember.GetHashCode());
}