Files
SwEdryG d03eabe7c9 Добавить Core/InputValidator.cs
Короткий класс для проверки который будет расширяться по степени развития приложения.
2026-06-10 23:13:51 +03:00

20 lines
596 B
C#

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