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