Advertisement
LeRoY_Go

Untitled

Feb 2nd, 2022
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2.  
  3. namespace C_Sharp_Junior
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool isExit = false;
  10.             while (isExit == false)
  11.             {
  12.                 isExit = ReadInt();
  13.             }
  14.             Console.ReadKey();
  15.         }
  16.         static bool ReadInt()
  17.         {
  18.             Console.Write("Введите строку:");
  19.             string userInput = Console.ReadLine();
  20.             bool result = int.TryParse(userInput, out int number);
  21.             if (result == true)
  22.             {
  23.                 Console.Write("Преобразование завершилось удачно: " + number);
  24.                 return true;
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine("Преобразование завершилось неудачно. Попробуйте сново.");
  29.                 return false;
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement