In C#, unlike Java, enums are not checked. You can have any value of the underlying type. This is why it’s pretty important to check your input.
if(!Enum.IsDefined(typeof(MyEnum), value))
throw new ArgumentOutOfRangeException();
In C#, unlike Java, enums are not checked. You can have any value of the underlying type. This is why it’s pretty important to check your input.
if(!Enum.IsDefined(typeof(MyEnum), value))
throw new ArgumentOutOfRangeException();