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()
- {
- while (true)
- {
- Console.Write("Введите строку:");
- string userInput = Console.ReadLine();
- bool result = int.TryParse(userInput, out int number);
- if (result == true)
- {
- return number;
- }
- else
- {
- Console.WriteLine("Преобразование завершилось неудачно. Попробуйте сново.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement