dxoraxs

Untitled

Apr 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homework
  4. {
  5.     class Program
  6.     {
  7.         static int ConvertToInt()
  8.         {
  9.             Console.WriteLine("Введите число: ");
  10.             bool success = false;
  11.             int result=0;
  12.             while (!success)
  13.             {
  14.                 success = int.TryParse(Console.ReadLine(), out result);
  15.                 if (!success) Console.WriteLine("Введено не число. Повторите попытку");
  16.                 else Console.WriteLine("Успешно!");
  17.             }
  18.             return result;
  19.         }
  20.         static void Main(string[] args)
  21.         {
  22.             int number = ConvertToInt();
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment