Defining and Using Enums

You can define custom enumeration types using the enum keyword.  Enums derive from System.Enum and consist of a list of named constants, which map to integer values.  An instance of the enum takes on the value of one of the constants.
Defining an enum:
1
2
3
4
5
6
7
public enum Mood
{
    Crabby,
    Happy,
    Petulant,
    Elated
}
Once you’ve defined an enum, you can declare variables of the new enum type and assign values to them.
1
Mood myMood = Mood.Elated;
Internally, each constant value in an enum is represented by a single integral value.  By default, the first constant listed has the value of 0 and consecutive constants have values that increment by one.  For example:
1
2
3
4
5
6
public enum DumbLevels
{
    Dumb,      // 0
    Dumber,    // 1
    Dumbest    // 2
}