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 READINT
- {
- class Program
- {
- static void Main(string[] args)
- {
- int readyValue;
- readyValue = ConvertStringToNumber();
- }
- static int ConvertStringToNumber()
- {
- int convertedValue = 0;
- string userEnteredValue;
- bool programOperation = true;
- while (programOperation)
- {
- Console.Write("Введите значение:");
- userEnteredValue = Console.ReadLine();
- bool result = int.TryParse(userEnteredValue, out convertedValue);
- if (result)
- {
- Console.WriteLine("Конвертация прошла успешно! Сконвертированное значение равно: " + convertedValue);
- programOperation = false;
- }
- else
- {
- Console.WriteLine("Конвертация прошла не удачно. Попробуйте другое значение");
- }
- }
- return convertedValue;
- }
- }
- }
Add Comment
Please, Sign In to add comment