d03eabe7c9
Короткий класс для проверки который будет расширяться по степени развития приложения.
20 lines
596 B
C#
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();
|
|
}
|
|
}
|
|
}
|
|
}
|