ranee

ReadInt

Apr 10th, 2021 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Dynamic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using System.IO;
  13. namespace CSLight
  14. {
  15.     class Program
  16.     {
  17.         static void Main(string[] args)
  18.         {
  19.             int number = ReadInt();
  20.             Console.WriteLine($"{number} является числом.");
  21.         }
  22.         static int ReadInt()
  23.         {
  24.             int number;
  25.             string command = "";
  26.             while (!int.TryParse(command, out number))
  27.             {
  28.                 Console.Write("Введите число:");
  29.                 command = Console.ReadLine();
  30.                 Console.Clear();
  31.             }
  32.             return number;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment