Enum.Format() : Enum « System « C# / C Sharp by API






Enum.Format()

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

  }
}

   
  








Related examples in the same category

1.Enum.GetNames
2.Enum.GetUnderlyingType()
3.Enum.IsDefined
4.Enum.Parse