Parse a string to an enum : System.Enum : Data Type C# Examples


C# Examples » Data Type » System.Enum »

 

Parse a string to an enum









    
using  System;

enum  EmployeeType  :  byte  
{
    Manager  =  10,
    Programmer  =  1,
    Contractor  =  100,
    Developer  =  9
}

class  MainClass
{
    public  static  void  Main(string[]  args)
    {
        
        EmployeeType  sally  =  (EmployeeType)Enum.Parse(typeof(EmployeeType),  "Manager");
        Console.WriteLine("Sally  is  a  {0}",  sally.ToString());
    }
}
    
   
  
   



Output

Sally is a Manager


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» System.Enum