Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- namespace FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- int userNumber = ConvertToInt();
- Console.WriteLine(userNumber);
- }
- static int ConvertToInt()
- {
- Console.WriteLine("Введите число");
- int output;
- bool enterIsCorrect = false;
- do
- {
- string input = Console.ReadLine();
- enterIsCorrect = int.TryParse(input, out output);
- if (!enterIsCorrect)
- {
- Console.WriteLine("Ложное значение. Повторите попытку");
- }
- } while (!enterIsCorrect);
- return output;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement