I've found this all over the place in this code:
public enum Blah: int { blah = 0, blahblah = 1 }
Why would it need to inherit from int? Does it ever need to?
According to the documentation:
Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int.
So, no, you don't need to use int. It would work with any integral type. If you don't specify any it would use int as default and it's this type that will be used to store the enumeration into memory.
1.4m articles
1.4m replys
5 comments
57.0k users