Enum.Parse : Enum « System « C# / C Sharp by API






Enum.Parse

 


using System;

enum Color
{
    red,
    green,
    yellow
}

public class MainClass
{
    public static void Main()
    {
        Color c = Color.red;
        
        // 
        c = (Color) Enum.Parse(typeof(Color), "Red", true);
        Console.WriteLine("string value is: {0}", c);
        
    }
}

   
  








Related examples in the same category

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