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 Learn1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = Number();
- Console.WriteLine($"Вы ввели - {num}");
- }
- static int Number()
- {
- bool isActive = true;
- string userInput;
- int number;
- while (isActive)
- {
- Console.WriteLine("Введите число:");
- userInput = Console.ReadLine();
- if (int.TryParse(userInput, out number))
- {
- return number;
- }
- else
- {
- Console.WriteLine("Вы ввели не число:");
- }
- }
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement