kwest87

Untitled

Apr 13th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp13
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int number = GetNumber();
  15.         }
  16.  
  17.         static void GetNumber()
  18.         {
  19.             bool isAttempt = true;
  20.  
  21.             while (isAttempt == true)
  22.             {
  23.                 Console.Write("Введите число : ");
  24.                 string data = Console.ReadLine();
  25.                 int number;
  26.  
  27.                 if (int.TryParse(data, out number))
  28.                 {
  29.                     Console.WriteLine(number);
  30.                     isAttempt = false;
  31.                     return;
  32.                 }
  33.  
  34.                 else
  35.                 {
  36.                     Console.WriteLine("Таких не бывает чисел .");
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
  42. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment