Код: Выделить всё
public enum MyEnum
{
First,
Second,
Third
}
Dictionary myDict = new Dictionary();
var types = Enum.GetValues(typeof(MyEnum));
int i = 1;
foreach (var val in types)
{
myDict.Add(val,i);
i++
}
Console.WriteLine(myDict[MyEnum.Second]);
Expected output:
2
Подробнее здесь: https://stackoverflow.com/questions/792 ... -enum-in-c
Мобильная версия