Advertisement
Briotar

Homework 4

May 11th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Homework4
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string userInput;
  10.             int number;
  11.             bool successfulConvert = false;
  12.  
  13.             while(!successfulConvert)
  14.             {
  15.  
  16.                 Console.Write("Введите число - ");
  17.                 userInput = Console.ReadLine();
  18.  
  19.                 successfulConvert = Int32.TryParse(userInput, out number);
  20.                 if (successfulConvert)
  21.                 {
  22.                     Console.WriteLine($"Вы ввели число - {number}");
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine("Преобразовать не вышло");
  27.                 }
  28.             }
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement