Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userInput;
- bool successfulConvert = false;
- while (!successfulConvert)
- {
- Console.Write("Введите число - ");
- userInput = Console.ReadLine();
- ConvertToInt(userInput, ref successfulConvert);
- }
- }
- static void ConvertToInt(string userInput, ref bool successfulConvert)
- {
- int number;
- successfulConvert = Int32.TryParse(userInput, out number);
- if (successfulConvert)
- {
- Console.WriteLine($"Вы ввели число - {number}");
- }
- else
- {
- Console.WriteLine("Преобразовать не вышло");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement