kwest87

Untitled

Apr 12th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp13
  9. {
  10. internal class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. GetNumber();
  15. }
  16.  
  17. static void GetNumber()
  18. {
  19. bool isAttempt = true;
  20.  
  21. while (isAttempt == true)
  22. {
  23. Console.Write("Введите число : ");
  24. string data = Console.ReadLine();
  25. int number;
  26.  
  27. if (int.TryParse(data, out number))
  28. {
  29. Console.WriteLine(number);
  30. isAttempt = false;
  31.  
  32. return ;
  33. }
  34.  
  35. else
  36. {
  37. Console.WriteLine("Таких не бывает чисел .");
  38. }
  39. }
  40. }
  41. }
  42. }
  43. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment