Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 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 ConsoleApp10
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             ConsoleColor defultColor = Console.ForegroundColor;
  14.             bool isOpen = true;
  15.             bool result;
  16.             string userInput;
  17.  
  18.             Console.Write("Введите число для конвертации: ");
  19.             while (isOpen)
  20.             {
  21.                 userInput = Console.ReadLine();
  22.                 result = int.TryParse(userInput, out int number);
  23.                 if (result == true)
  24.                 {
  25.                     Console.ForegroundColor = ConsoleColor.Green;
  26.                     Console.WriteLine("Конвертация удалась: " + number);
  27.                     Console.ForegroundColor = defultColor;
  28.  
  29.                    isOpen = false;
  30.                 }
  31.                 else
  32.                 {
  33.                     Console.ForegroundColor = ConsoleColor.Red;
  34.                     Console.WriteLine("Конвертация не удалась, повторите попытку!!!");
  35.                     Console.ForegroundColor = defultColor;
  36.  
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement