What is the point of having
enum SomeEnum : byte // <----
{
SomeValue = 0x01,
...
}
when you have to make a cast just to assign it to the same type of variable as the enums underlying type?
byte b = (byte)SomeEnum.SomeValue;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not much point, really, except that if the default underlying type (
int) is not enough for you, ie. you want to use higher integer values than that then you can make itlong. This can be useful when you have a[Flags]enum with more than 32 values.You can make it
byteorshortjust to restrict the range of values, but it will actually still take 4 bytes when used as a local variable (ie. same asint). It may however occupy less memory if used as an array.