Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homeWorkFunctionReadline
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int nubmer = GetNumber();
- Console.WriteLine($"Вы ввели число: {nubmer}");
- }
- static int GetNumber()
- {
- int result = 0;
- string userInput;
- bool isExit = false;
- while (isExit == false)
- {
- Console.Clear();
- Console.Write("Введите целое число: ");
- userInput = Console.ReadLine();
- if (int.TryParse(userInput, out result))
- {
- isExit = true;
- }
- else
- {
- Console.WriteLine("\nПожалуйства ведите корректное число.");
- }
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement