Advertisement
nassss

Untitled

Feb 24th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public static Priority ParseEnumPriority(string input)
  2. {
  3. while (true)
  4. {
  5. input = Console.ReadLine();
  6. var success = Enum.TryParse(input, true, out Priority parsedEnum);
  7.  
  8. if ((!Enum.IsDefined(typeof(Priority), parsedEnum)) || string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input) || (!success))
  9. {
  10. Console.WriteLine("Please enter a valid input that is between options above!");
  11. continue;
  12. }
  13. return parsedEnum;
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement