|
Author: Jenny Nguyen
|
|
Using C# Enumeration. We will need to use the enum keyword to declare the enumeration. Syntax: enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri}; (this set up will set the Sat to begin with the sequence from 0 onwards) eg 0,1,2,3,4,5,6 enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri}; (this setup will force the Sat to begin the sequence from 1 onwards). eg 1,2,3,4,5,6,7 { North, East, South, West }
enum Direction { North = 0, East = 90, South = 180, West = 270 }
//Casting to the get the value from the list
foreach (string navigation in Enum.GetNames(typeof(Navigation))) { Console.WriteLine("Enumeration values: {0}\n Value: {1}", navigation, (int)Enum.Parse(typeof(Navigation), navigation)); }
|