What's the point of using : int in the enum declaration as following?
public enum AAType : int
{
Folder = 0,
File = 1, 开发者_如何学运维
Link = 2
}
The default underlying type of an enum
is int
, so by specifying it explicitly you only (perhaps) gain in clarity, but the behavior's just the same as if : int
was omitted.
The default backing type of enum
is int
. You can change the backing type to something else, like short
or long
. Specifying int
is probably just for clarity.
The fact that an Enum is a specialized Int you can use bytes for each Enum value (Apple = 1, Pear = 2, Orange = 4) and then you can pass the Enums in Piped and determine what to do based on the byte value (look at Reflection.BindingFlags, etc).
精彩评论