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 fro
You don't need to inherit from int but by default it does. You can inherit from other integral types (byte, long, etc) if you want to. An example would be if you wanted to save memory or column space in a DB.
Enums are implicitly backed by integers.
: int just restates the default, just like void M(); vs. private void M();.
You can also create enums that are backed by other intergral types, such as enum GiantEnum : long.
Most of the time I don’t care if an enum is signed or unsigned, or how many bits it has, so I just let the system use it’s default that is int.
However there are times when I do care that the enum is a signed 32 bit int, and then it is good to make it clear that I do care. I would expect a comment as well spelling out why I care.