Last active
March 14, 2024 11:38
-
-
Save kyzalex/f827c9e91d3a79521ad29097e9b48003 to your computer and use it in GitHub Desktop.
ReadInt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int number = ReadNumber(); | |
Console.WriteLine($"Преобразование прошло успешно. Число: {number}"); | |
Console.ReadKey(); | |
} | |
static int ReadNumber() | |
{ | |
int number = 0; | |
Console.Write("Введите число :"); | |
while (int.TryParse(Console.ReadLine(), out number) == false) | |
{ | |
Console.WriteLine("Преобразование завершилось неудачно"); | |
} | |
return number; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment