I can define an enum with integer as value:
public enum FieldType
{
Bar = 0,
Foo = 1
}
Why C# doesn't allow creating a dictionary with integer as a key and using an enum value when creating:
public Dictionary<int, Type> _fieldMapping = new Dictionary<int, Type>
{
{FieldType.Bar, null}, # Error in VS
{FieldType.Foo, null}, # Error in VS
}
I know i can do a cast, but i would like to know why enum cannot be converted to int implicitly when it actually is int under the hood.