Advertisement
pol9na

Untitled

Mar 22nd, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Study
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             numberCheck();
  14.         }
  15.  
  16.         static int numberCheck ()
  17.         {
  18.             int number;
  19.             bool exit=true;
  20.             while (exit==true)
  21.             {
  22.                 Console.WriteLine("Введите строку:");
  23.                 string input = Console.ReadLine();
  24.                
  25.                 bool result = int.TryParse(input, out number);
  26.                 if (result == true)
  27.                 {
  28.                     Console.WriteLine("Преобразование прошло успешно");
  29.                     exit = false;
  30.                 }
  31.                 else
  32.                 {
  33.                 Console.WriteLine("Преобразование завершилось неудачно");
  34.            
  35.                 }
  36.                 return number;
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement