I have this simple enum;
public enum MyEnum
{
FOO = 1,
BOO = 2,
}
I could use GetValues
or GetNames
but that excludes the other :-/
I have this simple enum;
public enum MyEnum
{
FOO = 1,
BOO = 2,
}
I could use GetValues
or GetNames
but that excludes the other :-/
If I understand your question correctly
var dict = Enum.GetValues(typeof(MyEnum))
.Cast<int>()
.ToDictionary(x => Enum.GetName(typeof(MyEnum), x), x => x);