Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ReadInt
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int number = GetNumber();
- Console.WriteLine($"Вы ввели число - {number}");
- }
- public static int GetNumber()
- {
- bool isWorking = true;
- int number = 0;
- while (isWorking)
- {
- Console.WriteLine("Введите число");
- bool isSuccess = int.TryParse(Console.ReadLine(), out number);
- if (isSuccess)
- {
- isWorking = false;
- }
- else
- {
- Console.WriteLine("Ошибка, нужно вводить число. Повторите еще раз.");
- Console.ReadKey();
- Console.Clear();
- }
- }
- return number;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement