Добавить Core/InputValidator.cs
Короткий класс для проверки который будет расширяться по степени развития приложения.
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user