Visual C# Guide
Enumerated Types

An enumerated type is a set of ordered values. Each value is given a number, starting at zero (all counting systems in C# programming start from 0).

The following example defines an enumerated type called Rainbow which contains the colours of the rainbow in order.

class Program
{
   enum Rainbow {Red, Orange, Yellow, Green, Blue, Indigo, Violet};

      static void Main(string[] args)
      {
         int colour1 = (int)Rainbow.Red;
         int colour2 = (int)Rainbow.Indigo;
         Console.WriteLine("Red is colour {0}", colour1);
         Console.WriteLine("Indigo is colour {0}", colour2);
         Console.ReadLine();
      }
}

Notice in the variable declarations how we converted the right hand side of the statement into an integer by preceding it with (int).

Having A Go

  1. Study the example above. Look back at the page on the DateTime structure. Use this information to output the date and time using words for the month and day.