Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ReadInt_02
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool doExit = false;
- bool result = false;
- int number;
- while (doExit == false)
- {
- if (CheckNumber(out number))
- {
- Console.WriteLine($"Вы ввели число {number}");
- Console.ReadKey();
- doExit = true;
- }
- else
- {
- Console.Clear();
- Console.WriteLine("Это не целое число");
- }
- }
- }
- static bool CheckNumber(out int number)
- {
- string userInput;
- bool result;
- Console.Write($"Введите любое целое число: ");
- userInput = Console.ReadLine();
- result = int.TryParse(userInput, out number);
- return result;
- }
- }
- }
Add Comment
Please, Sign In to add comment