Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Lesson_4._3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Ваше число: " + IntParser());
  14.  
  15.             Console.ReadKey();
  16.         }
  17.         static int IntParser()
  18.         {
  19.             int result = 0;
  20.             bool isPrseSucsess = false;
  21.  
  22.             while (!isPrseSucsess)
  23.             {
  24.                 Console.WriteLine("Введите число:");
  25.                 isPrseSucsess = int.TryParse(Console.ReadLine(), out result);
  26.  
  27.                 if (!isPrseSucsess)
  28.                 {
  29.                     Console.WriteLine("Некорректный ввод! Повторите попытку!");
  30.                 }
  31.             }
  32.  
  33.             return result;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement