Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             TryToInt();
  10.         }
  11.         static int TryToInt()
  12.         {
  13.             string userInput;
  14.             int number;
  15.  
  16.             do
  17.             {
  18.                 Console.WriteLine("Введите число");
  19.                 userInput = Console.ReadLine();
  20.  
  21.             } while (!int.TryParse(userInput, out number));
  22.  
  23.             return number;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement