您的位置:首页 > 其它

判断IP地址是否合法类

2016-04-13 09:47 344 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPFlag
{
public class Class1
{
public bool ISIP(string ip)
{
bool b = true;
string[] lines = new string[4];
string s = ".";
lines = ip.Split(s.ToCharArray(), 4);//分隔字符串
try
{
for (int i = 0; i < 4; i++)
{
if (Convert.ToInt32(lines[i]) >= 255 || Convert.ToInt32(lines[i]) < 0)
{
b = false;
return b;
}
}
return b;
}
catch { return false; }
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: