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(); + } + } + } +}