kwest87

Untitled

Mar 6th, 2024
96
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.             TruParse(out int transformationInput);
  10.             Console.WriteLine(transformationInput);
  11.         }
  12.  
  13.         static void TruParse(out int transformationInput)
  14.         {
  15.             bool isWork = true;
  16.             transformationInput = 0;
  17.  
  18.             while (isWork)
  19.             {
  20.                 Console.WriteLine("Укажите число :");
  21.                 string userInput = Console.ReadLine();
  22.  
  23.                 if (int.TryParse(userInput, out int number) == true)
  24.                 {
  25.                     transformationInput = Convert.ToInt32(number);
  26.                     Console.WriteLine("Корректно.");
  27.                     isWork = false;
  28.                 }
  29.                 else
  30.                 {
  31.                     Console.WriteLine("Ввод не число.");
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment