C# 判断IP是否合法

public static bool IsIP(string IP)
{
var iCount = IP.Split('.').Count();
if (iCount != 4)
{
return false;
}
IPAddress ip;
if (IPAddress.TryParse(IP, out ip))
{
return true;
}
else
{
return false;
}
}

posted @ 2020-07-20 18:17  Elcser  阅读(627)  评论(0编辑  收藏  举报