Advertisement
TwinFrame

ReadInt

Jan 15th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clight_16_ReadInt
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. bool actualNum = false;
  10. while (actualNum == false)
  11. {
  12. EnterNumber(actualNum);
  13. Console.Clear();
  14. }
  15. }
  16. static void EnterNumber(bool actualNum)
  17. {
  18. Console.Write("Введите число: ");
  19. string tempNum = Console.ReadLine();
  20.  
  21.  
  22. int number;
  23. bool goodNum = Int32.TryParse(tempNum, out number);
  24.  
  25. if (goodNum)
  26. {
  27. actualNum = true;
  28. Console.WriteLine("\nВаше число: " + number);
  29. Console.ReadKey();
  30. }
  31. else
  32. {
  33. Console.WriteLine("\nПопробуйте еще раз.");
  34. Console.ReadKey();
  35. Console.Clear();
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement