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