Advertisement
levamurashev2002

Untitled

Jul 9th, 2019
87
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp13
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int y = readint();
  14. Console.WriteLine(y);
  15. Console.WriteLine();
  16.  
  17. }
  18. static int readint()
  19. {
  20. int num;
  21. while (true)
  22. {
  23. Console.WriteLine("Введите число");
  24. Console.WriteLine();
  25. string x = Console.ReadLine();
  26. Console.WriteLine();
  27. bool a = Int32.TryParse(x, out num);
  28. if (a)
  29. {
  30. break;
  31. }
  32. else
  33. {
  34. Console.WriteLine("Должно быть число");
  35. Console.WriteLine();
  36. }
  37. }
  38. return (Convert.ToInt32(x));
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement