string str = "Dog";
Animal animal = (Animal)Enum.Parse(typeof(Animal), str); // Animal.Dog
Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // Case insensitiveIn this Code we will learn how to convert String to Enum.
In this Code we will learn how to convert String to Enum.
string str = "Dog";
Animal animal = (Animal)Enum.Parse(typeof(Animal), str); // Animal.Dog
Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // Case insensitive