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:-
1.
Enums type can be
an integer (float, int, byte, double, etc.) but if you use beside int, it has
to be cast.
2.
Enumerations
(enums) make your code much more readable and understandable.
3.
enum values are fixed. enum can be displayed as a string and processed as an integer.
4.
The default type
is int, and the approved types are byte, sbyte, short, ushort, uint, long,
and ulong.
5.
Every enum type automatically derives from System. Enum and thus we can use System.Enum
methods on enums.
6.
Enums are value
types and are created on the stack and not on the heap.
7.
Enums are not for
end-users, they are meant for developers.
8.
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.
9.
Enums type can
be an integer (float, int, byte, double, etc.) but if you use beside int, it has to be cast.
|