Convert a string to an Enumeration

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 1656
namespace ConsoleApp
{
class Program3
{
static void Main(string[] args)
{
var result = Enum.Parse(typeof(Colors), "Green");

Console.WriteLine(result.GetType());

Console.Read();
}
}

enum Colors
{
Red, Blue, Green, Purple
}
}


Result

ConsoleApp.Colors

Comments or Responses

Login to post response