What is the output of the following code?
using System; class Program { enum TrafficLight : byte { red, green, yellow }; enum Values { val1 = 12, val2 = (int)TrafficLight.green, val3, val4 = 200 }; static void Main(string[] args) { foreach (Values v in Enum.GetValues(typeof(Values))) { Console.WriteLine("{0} is storing {1}", v, (int)v); } Console.ReadKey(); } }
val2 is storing 1 val3 is storing 2 val1 is storing 12 val4 is storing 200
You can use other integer types as the backend type of enum.