An enumeration is actually a named integer type. For instance.
public enum Foo : int { SomeValue = 100, }
which means that you are creating an Foo enum with type 'int' and some value. I personally always make this explicit to show what is happening, but C # implicitly makes it "int" (32-bit int).
You can use any name for enumeration names and you can check if it is a valid enum using Enum.IsDefined (for example, to check if 300 is a valid rename name).
Update
Well, actually this is not 100% correct, to be honest. This update is just to show what is really happening under the hood. An enumeration is a value type with fields that act as names. For instance. the above listing is actually:
public struct Foo { private int _value; public static Foo SomeValue { get { return new Foo() { _value = 100 }; } } }
Note that 'int' is an int type (explicit in my case). Since this is a value type, it has the same structure as a real integer in memory, which is probably what the compiler uses to create it.
source share