Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

String to enum C#

string str = "Dog";
Animal animal = (Animal)Enum.Parse(typeof(Animal), str);  // Animal.Dog
Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // case insensitive

Source by www.csharp-examples.net #
 
PREVIOUS NEXT
Tagged: #String #enum
ADD COMMENT
Topic
Name
9+9 =