51Aspx源码必读.txt
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
IP地址段转换为掩码源码
IP地址段转换为掩码源码
源码描述:
IP地址段转换为掩码
代码片段:
string yanma = "";
string startIPbinary = ConvertToBinary(startIP);//将IP转换成二进制,格式00000000.00000000.00000000.00000000.
string stopIPbinary = ConvertToBinary(stopIP);//将IP转换成二进制
string[] startIPs = startIPbinary.Split(new[] {'.'});//将转换好的二进制,以“.”分割成字符串数组。
string[] endIPs = stopIPbinary.Split(new[] { '.' });//将转换好的二进制,以“.”分割成字符串数组。
for (int i = 0; i < 4; i++)
{
if (startIPs[i] == endIPs[i])
{
yanma += 255.ToString()+".";
}
else
{
char[] startIPchar = StringToChar(startIPs[i].ToString());
char[] stopIPchar = StringToChar(endIPs[i].ToString());
int count = 0;
for (int j = 0; j < 8; j++)
{
if (stopIPchar[j] == startIPchar[j])
{
count++;
}
else
break;
}
double h = 0;
for (int k = 7; k >=8 - count; k--)
{
h += Math.Pow(2, k);
}
yanma += h.ToString();
break;
}
}
if (yanma.Split(new[] {'.'}).Length != 4)
{
for (int i = 0; i < 4 - yanma.Split(new[] {'.'}).Length; i++)
{
yanma += ".0";
}
}
return yanma;
}
作者: 瞳寒summer
如需获得该源码的视频、更新等更多资料请访问: https://www.51aspx.com/project/IPMaskDemo
------------------------------------------------------------------------------------------------
后面还有 16 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
