Why use int in an enum declaration?

What is the point of using : int in an enumeration declaration as follows:

public enum AAType : int { Folder = 0, File = 1, Link = 2 } 
+4
source share
3 answers

The default support type enum is int . You can change the type of support to something else, such as short or long . An int possible, just for clarity.

+6
source

The enum type is int default, so by explicitly specifying it you can (possibly) get clarity, but the behavior was the same as if : int were omitted.

+7
source

The fact that Enum is a specialized Int, you can use bytes for each Enum value (Apple = 1, Pear = 2, Orange = 4), and then you can pass Enums in Piped and determine what to do based on the byte (look at Reflection.BindingFlags, etc.).

-3
source

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


All Articles