Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp10
- {
- class Program
- {
- static void Main(string[] args)
- {
- ConsoleColor defultColor = Console.ForegroundColor;
- bool isOpen = true;
- bool result;
- string userInput;
- Console.Write("Введите число для конвертации: ");
- while (isOpen)
- {
- userInput = Console.ReadLine();
- result = int.TryParse(userInput, out int number);
- if (result == true)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Конвертация удалась: " + number);
- Console.ForegroundColor = defultColor;
- isOpen = false;
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Конвертация не удалась, повторите попытку!!!");
- Console.ForegroundColor = defultColor;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement