Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string pet = "Dog";
- PetType petType = (PetType)Enum.Parse(typeof(PetType), pet);
- int petValue = (int)petType;
- PetType result;
- if (Enum.TryParse<PetType>(pet, out result))
- return (int)result;
- else
- throw something with an error message
- (PetType)Enum.Parse(typeof(PetType), pet)
- PetType petTypeA = (PetType)Enum.Parse(typeof(PetType), "Dog");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement