編程語言
類 別
主要功能
using System;
using System
using System
using System
namespace IPUtility
{
class Program
{
static void Main(string[] args)
{
IPRangeManage irm = new IPRangeManage();
irm
irm
irm
irm
Console
Console
}
}
public class IPRange
{
private string _Name = string
private ulong _BeginIP =
private ulong _EndIP = Int
/**//// <summary>
/// IP段名稱
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// ?始IP
/// </summary>
public ulong BeginIP
{
get { return _BeginIP; }
set { _BeginIP = value; }
}
/**//// <summary>
/// ?束IP
/// </summary>
public ulong EndIP
{
get { return _EndIP; }
set { _EndIP = value; }
}
/**//// <summary>
/// 此IP段的范?
/// </summary>
public ulong Range
{
get
{
return EndIP
}
}
public IPRange(string name
{
this
this
this
}
public static ulong IP
{
byte[] bytes = IPAddress
ulong ret =
foreach (byte b in bytes)
{
ret <<=
ret |= b;
}
return ret;
}
public static int Compare(IPRange x
{
if(x
return
else if(x
return
else return
}
}
public class IPRangeManage
{
public IPRangeManage()
{ }
private List< IPRange> _IPRangeList = new List< IPRange>();
private bool _NeedSort = true;
public void Add(IPRange ipRange)
{
_IPRangeList
_NeedSort = true;
}
private void Sort()
{
if (_NeedSort)
{
_IPRangeList
}
}
public IPRange Search(string ipString)
{
ulong ip = IPRange
this
foreach (IPRange ir in _IPRangeList)
{
if (ir
{
return ir;
}
}
return null;
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/12757.html