The enum is
used to declare a list of named integer constants. It can be defined using the
enum keyword directly inside a namespace, class, or structure.so Enum
is a value type with a set of related named constants , The enum keyword is
used to declare an enumeration, a distinct type that consists of a set of named
constants called the enumerator list.
Example:-1
|
enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};
|
Note:-
|
·
Enums type can be an integer (float,
int, byte, double etc.) but if you use beside int, it has to be cast.
· Enumerations (enums) make your code
much more readable and understandable.
· enum values are fixed. enum can be
displayed as a string and processed as an integer.
· The default type is int, and the
approved types are byte, sbyte, short, ushort, uint, long, and ulong.
· Every enum type automatically derives
from System.Enum and thus we can use System.Enum methods on enums.
·
Enums are value types and are created
on the stack and not on the heap.
·
Enums are not for end-users, they are
meant for developers.
·
Enum is a value type with a set of
related named constants ,The enum keyword is used to declare an enumeration,
a distinct type that consists of a set of named constants called the
enumerator list.
·
Enums type can be an integer (float,
int, byte, double etc.) but if you use beside int, it has to be cast.
|