Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C_sharp_Light
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = 0;
- number = RequestsAndConvertToInt();
- Console.WriteLine($"Ваше число - {number}");
- Console.ReadKey();
- }
- static int RequestsAndConvertToInt()
- {
- string value;
- int result;
- while (true)
- {
- Console.Write("Введите число: ");
- value = Console.ReadLine();
- if (int.TryParse(value, out result))
- {
- Console.WriteLine("Конвертация прошла успешно");
- Console.ReadKey();
- Console.Clear();
- return result;
- }
- else
- {
- Console.WriteLine("Конвертация прошла не успешно. Попробуйте ещё раз.");
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement