Advertisement
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_03
- {
- class Program
- {
- static void Main(string[] args)
- {
- ReadInt();
- Console.ReadKey();
- }
- static int ReadInt()
- {
- bool result;
- int number;
- while (true)
- {
- Console.Write($"Введите целое число: ");
- result = int.TryParse(Console.ReadLine(), out number);
- if(result == true)
- {
- Console.WriteLine($"Вы ввели число {number}");
- return number;
- }
- else
- {
- Console.Clear();
- Console.WriteLine($"что-то пошл не так");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement