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 Homework30
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- ConvertNumber();
- }
- static int ConvertNumber()
- {
- bool isConverted = true;
- int convertedNumber = 0;
- while (isConverted)
- {
- Console.WriteLine("Введите число для конвертации: ");
- string userInputNumber = Console.ReadLine();
- bool result = int.TryParse(userInputNumber, out var number);
- if (result == true)
- {
- Console.WriteLine($"Преобразование прошло успешно. Число: {number}");
- isConverted = false;
- }
- else
- {
- Console.WriteLine("Преобразование завершилось неудачно");
- Console.ReadKey();
- Console.Clear();
- }
- }
- return convertedNumber;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement