C# 判断是否为IP地址

string ipStr="172.27.190.117";
IPAddress ip;
if(IPAddress.TryParse(ipStr,out ip))
{
    MessageBox.Show("合法IP");
}
else
{
   MessageBox.Show("非IP");
}

原文地址:https://www.cnblogs.com/ssjsk/p/5826451.html