Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ReadInt
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите число для конвертации:");
- int numberFromUser = GetNumber();
- Console.ReadKey();
- }
- static int GetNumber()
- {
- int number = 0;
- bool isWork = true;
- while (isWork)
- {
- string userInput = Console.ReadLine();
- if (int.TryParse(userInput, out number))
- {
- Console.WriteLine("Число сконвертировано!");
- isWork = false;
- }
- else
- {
- Console.WriteLine("Некорректный ввод попробуйте снова!");
- }
- }
- return number;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement