Advertisement
levamurashev2002

Untitled

Jul 9th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 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. string x;
  21. int num;
  22. while (true)
  23. {
  24. Console.WriteLine("Введите число");
  25. Console.WriteLine();
  26. x = Console.ReadLine();
  27. Console.WriteLine();
  28. bool a = Int32.TryParse(x, out num);
  29. if (a)
  30. {
  31. break;
  32. }
  33. else
  34. {
  35. Console.WriteLine("Должно быть число");
  36. Console.WriteLine();
  37. }
  38. }
  39. return (Convert.ToInt32(x));
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement