Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 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 Task3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int number = ReadInt();
  14.  
  15.             Console.WriteLine("Вы ввели число: " + number);
  16.  
  17.             Console.ReadKey();
  18.         }
  19.  
  20.         static int ReadInt()
  21.         {
  22.             int number;
  23.             string input = "";
  24.  
  25.             while (false == int.TryParse(input, out number))
  26.             {
  27.                 Console.Write("Введите число:");
  28.                 input = Console.ReadLine();
  29.             }
  30.  
  31.             return number;
  32.         }
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement