Добавить Core/InputValidator.cs

Короткий класс для проверки который будет расширяться по степени развития приложения.
This commit is contained in:
2026-06-10 23:13:51 +03:00
parent 3fd560f583
commit d03eabe7c9
+19
View File
@@ -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();
}
}
}
}