SHARE
TWEET

Untitled

a guest Aug 13th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string pet = "Dog";
  2. PetType petType = (PetType)Enum.Parse(typeof(PetType), pet);
  3. int petValue = (int)petType;
  4.    
  5. PetType result;
  6. if (Enum.TryParse<PetType>(pet, out result))
  7.     return (int)result;
  8. else
  9.     throw something with an error message
  10.    
  11. (PetType)Enum.Parse(typeof(PetType), pet)
  12.    
  13. PetType petTypeA = (PetType)Enum.Parse(typeof(PetType), "Dog");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top