Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Get an enums type, hex and value

using System; enum EmployeeType : byte  {   Manager = 10,   Programmer = 1,   Contractor = 100,   Developer = 9 } class MainClass {   public static void Main(string[] args)   {          EmployeeType fred;     fred = EmployeeType.Developer;          Console.WriteLine("You are a {0}", fred.ToString());     Console.WriteLine("Hex value is {0}", Enum.Format(typeof(EmployeeType), fred, "x"));     Console.WriteLine("Int value is {0}", Enum.Format(typeof(EmployeeType), fred, "D"));   } } You are a Developer Hex value is 09 Int value is 9