Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

casting string to enum type

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: #casting #string #enum #type
ADD COMMENT
Topic
Name
6+6 =