Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberUser = VerificationConvert();
- Console.WriteLine($"Возвращенное число: {numberUser}");
- }
- static private int VerificationConvert()
- {
- int number;
- while (true)
- {
- Console.Write("Введите число: ");
- string userInput = Console.ReadLine();
- bool success = Int32.TryParse(userInput, out number);
- if (success)
- {
- return number;
- }
- else
- {
- Console.WriteLine($"Попытка преобразования '{userInput}' неудачна.");
- }
- }
- }
- }
- }
RAW Paste Data