Advertisement
AlexRaynor

4.3 ReadInt

Sep 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 ConsoleApp21
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             while (true)
  15.             {
  16.                 ReadInt();
  17.  
  18.             }
  19.  
  20.  
  21.         }
  22.  
  23.         static void ReadInt()
  24.         {
  25.             string UserInput;
  26.             int number;
  27.             Console.WriteLine("Введите число");
  28.             UserInput = Console.ReadLine();
  29.             bool success = Int32.TryParse(UserInput, out number);
  30.             if (success)
  31.             {
  32.                 Console.WriteLine("Сконвертировано " + number);
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine("Сконвертировать не удалось");
  37.             }
  38.         }
  39.  
  40.  
  41.  
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement