kwest87

Untitled

Apr 23rd, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp30
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number;
  10.             number = CheckNumber();
  11.             Console.WriteLine(number);
  12.         }
  13.  
  14.         static int CheckNumber()
  15.         {
  16.             bool isWork = true;
  17.             int transformationInput = 0;
  18.  
  19.             while (isWork)
  20.             {
  21.                 Console.WriteLine("Укажите число :");
  22.                 string userInput = Console.ReadLine();
  23.  
  24.                 if (int.TryParse(userInput, out int number) == true)
  25.                 {
  26.                     transformationInput = number;
  27.                     Console.WriteLine("Корректно.");
  28.                     isWork = false;
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.WriteLine("Ввод не число.");
  33.                 }
  34.             }
  35.  
  36.             return transformationInput;
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment