Mega Code Archive

 
Categories / C# / Data Types
 

Get Enums type, hex and value

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