Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What difference does it make if I inherit enum from Byte in C#

Tags:

c#

enums

I am trying to figure out the difference between these two enums

    public enum EnumA
    {
        A = 1,
        B = 2,
        C = 3
    }

vs

   public enum EnumB : byte
    {
        A = 1,
        B = 2,
        C = 3
    }

I know that the default base type of enum is int, so If I change base type to byte how its going to impact?

like image 416
zash707 Avatar asked Oct 30 '15 03:10

zash707


1 Answers

You will only be able to use value 0-255 for the enum. This is probably plenty, if you're not using the enum as flags, then you are limited to only 8 different flags.

like image 198
Molibar Avatar answered Oct 26 '22 16:10

Molibar