Enumerations
Posted by Gizmosis350k
Last Updated: April 07, 2012
  3140

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ch05Ex02
{
   enum orientation : byte
   {
      north = 1,
      south = 2,
      east = 3,
      west = 4
   }

   class Program
   {
      static void Main(string[] args)
      {
         // Commented code is for the second part the of the Try it Out.
         //byte directionByte;
         //string directionString;
         orientation myDirection = orientation.north;
         Console.WriteLine("myDirection = {0}", myDirection);
         //directionByte = (byte)myDirection;
         //directionString = Convert.ToString(myDirection);
         //Console.WriteLine("byte equivalent = {0}", directionByte);
         //Console.WriteLine("string equivalent = {0}", directionString);

         Console.ReadKey();
      }
   }
}


This type of variable is used for specialized value storage. Very useful if you know how to handle it.
I'm looking into it now, but i will be skimming over some content to see where this fits in on the grand scheme of things xD
   
  
 
 
   

 
 

The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1. For example:

enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};
 
I see