If you declare an enum in C#, the default type is automatically int.
So then why in a case statement or other instances when using the enum do you have to explicitly recast in order to use the values? What's the point of having an underlying type if you have to explicitely case or am I just doing something wrong here?
private enum MyEnum
{
Value1,
Value2,
Value3
}
switch (somevalue)
{
case (int)MyEnum.Value1:
someothervar = "ss";
break;
case (int)MyEnum.Value2:
someothervar = "yy";
break;
case (int)MyEnum.Value3:
someothervar = "gg";
break;
}