I have an enum with a custom value for only part of the list
public enum MyEnum { FirstValue, SecondValue, ThirdValue, ForthValue = 1, FifthValue = 2 }
When I tried strina name = (MyEnum)2; the name was ThirdValue .
But when I changed enum to
public enum MyEnum { FirstValue = 3, SecondValue, ThirdValue, ForthValue = 1, FifthValue = 2 }
In strina name = (MyEnum)2; the name was FifthValue .
Is the compiler (I'm using Visual Studio 2012) to initialize user values only if the former have user values?
And if ThirdValue got the default value of 2 in the first example, why was there no error in FifthValue = 2 ?
source share