Advertisement
Tellexxii

1.3.6.4

Jul 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Net;
  7. using System.Threading;
  8.  
  9. namespace IMJunior
  10. {
  11.     class Program
  12.     {
  13.         //public static string myNumber;
  14.  
  15.         static void Main(string[] args)
  16.         {
  17.             Console.WriteLine("Введите число");
  18.             IntReterner();
  19.             Console.WriteLine("Вы ввели число");
  20.         }
  21.         public static int IntReterner()
  22.         {
  23.             string myNumber = Console.ReadLine();
  24.             int intParsed;
  25.                        
  26.             bool result = int.TryParse(myNumber, out intParsed);
  27.            
  28.             while (!result)
  29.             {
  30.                 Console.WriteLine("Это не число");
  31.                 myNumber = Console.ReadLine();
  32.                 result = int.TryParse(myNumber, out intParsed);
  33.             }
  34.                
  35.             return intParsed;
  36.         }
  37.        
  38.     }
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement