I have an enum like:
public enum Test:int
{
A=1,
B=2
}
So here I know my enum is an int type but if I want to do something like following:
int a = Test.A;
this doesn’t work.
If I have a class like:
public class MyTest
{
public static int A =1;
}
I can say ,
int a = MyTest.A;
Here I don’t need to cast A to int explicitly.
With your updated example:
And usage:
That’s not how enums look. Enums look more like (comments are places where we differ from a real enum):
Yes, you can easily get to the “underlying” int value, but the values of
AandBare still strongly typed as being of typeMyTest. This makes sure you don’t accidentally use them in places where they’re not appropriate.