Advertisement
Rodunskiy

Untitled

May 22nd, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. class program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         bool isWorking = true;
  6.  
  7.         while (isWorking)
  8.         {
  9.             Console.Clear();
  10.             Console.Write("Введите любое число:");
  11.             string userInput = Console.ReadLine();
  12.             Int32Converter(ref userInput,ref isWorking);
  13.         }
  14.     }
  15.  
  16.     static void Int32Converter(ref string number, ref bool isExit)
  17.     {
  18.         bool isresult = int.TryParse(number, out int x);
  19.  
  20.         if (isresult == true)
  21.         {
  22.             Console.WriteLine($"Преобразование прошло успешно. Число: {number}");
  23.             isExit = false;
  24.             Console.ReadKey();
  25.         }
  26.         else
  27.         {
  28.             Console.WriteLine("Преобразование завершилось неудачно");
  29.             Console.ReadKey();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement