CSharp examples for Custom Type:Enum
To change the default type, you use the following format:
modifiers enum enumName : typeName { member(s) }
using System;//from ww w. j a v a2s . co m class MainClass { enum Color : byte { red, white, blue } public static void Main() { Color myColor; byte roll; System.Random rnd = new System.Random(); for ( int i = 0; i < 10; i++ ) { roll = (byte) (rnd.Next(0,3)); // random nbr from 0 to 2 myColor = (Color) roll; System.Console.WriteLine("Color is {0} ({1} of type {2})", myColor, (byte) myColor, myColor.GetTypeCode()); } } }