Advertisement
NikaBang

ReadInt

May 31st, 2022 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1.     static int ReadInt(string convert)
  2.     {
  3.         bool success = int.TryParse(convert, out int number);
  4.  
  5.         while (success == false)
  6.         {
  7.             Console.Write("Ошибка конвертации, повторите ввод: ");
  8.             success = int.TryParse(Console.ReadLine(), out number);
  9.         }
  10.         return number;
  11.     }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement