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
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = TryParse();
- Console.WriteLine(number);
- Console.ReadKey();
- }
- static int TryParse()
- {
- bool trueParse = false;
- int number = 0;
- while (!trueParse)
- {
- Console.Clear();
- Console.Write("Введите число: ");
- string stringNumber = Console.ReadLine();
- if (Int32.TryParse(stringNumber, out number))
- {
- trueParse = true;
- Console.WriteLine("Ура!");
- }
- }
- return number;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment