Get Enum's type, hex and value.

image_pdfimage_print
   
   
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"));

    }
}

   
    
     


This entry was posted in Data Types. Bookmark the permalink.