From d03eabe7c9b697ca070dd96cb7a2da46fde933b0 Mon Sep 17 00:00:00 2001 From: SwEdryG Date: Wed, 10 Jun 2026 23:13:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20Core/InputValidator.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Короткий класс для проверки который будет расширяться по степени развития приложения. --- Core/InputValidator.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Core/InputValidator.cs diff --git a/Core/InputValidator.cs b/Core/InputValidator.cs new file mode 100644 index 0000000..335291b --- /dev/null +++ b/Core/InputValidator.cs @@ -0,0 +1,19 @@ +namespace IP_port_checker.Core +{ + class InputValidator + { + public static int StEnPort(string promt) + { + while (true) + { + Console.Write(promt); + string? input = Console.ReadLine(); + if (int.TryParse(input, out int port) && port >= 1 && port <= 65535) + return port; + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Ошибка: введите число от 1 до 65535"); + Console.ResetColor(); + } + } + } +}