All enumeration types are value types, and different members are also inferred from member types (valid types are byte , sbyte , short , ushort , int , uint , long , or ulong - as documented ).
This means enumeration members cannot be null .
One way to deal with the default enum value is to put the value None as the first value and set it to a negative value (for signed enumerations) or 0 .
public enum MyEnum { [StringValue(null)] None = -1, [StringValue("X")] MyX, [StringValue("Y")] MyY }
Could you have a null reference to an enumeration if you declare a nullable instance - myenum? .
Odded
source share