Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. while(true)
  4. {
  5. Console.Write("Choose an option (1, 2, 3)? ");
  6. var option = Console.ReadLine();
  7.  
  8. switch (option)
  9. {
  10. case "1":
  11. case "2":
  12. Console.WriteLine("You did not win :(");
  13. break;
  14. case "3":
  15. Console.WriteLine("You won!");
  16. break;
  17. default:
  18. Console.WriteLine("This is not an option.");
  19. break;
  20. }
  21.  
  22. Console.Write("Type quit to exit or press ENTER to continue...");
  23. var input = Console.ReadLine();
  24.  
  25. // Make it all uppercase so we don't have to guess what the user typed in.
  26. // We just care about the word.
  27. if (input.ToUpper() == "QUIT")
  28. {
  29. // Break out of the loop which will end the app
  30. break;
  31. }
  32.  
  33. // Clear the console of the previous inputs for a clean start
  34. Console.Clear();
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement