Who cares if I inherit an enumeration from a byte in C #

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

    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 enum is int, so if I change the base type to byte, how will it affect?

+4
source share
1 answer

You can only use a value of 0-255 for an enumeration. This is probably a lot if you do not use enum as flags, then you are limited to only 8 different flags.

+3
source

Source: https://habr.com/ru/post/1613764/


All Articles