Exemplo n.º 1
0
 /// <summary>
 /// 根据子网地址和掩码地址初始化子网类
 /// </summary>
 /// <param name="_ip">子网地址</param>
 /// <param name="_mask">掩码地址</param>
 public Subnet(IpAddress _ip, IpAddress _mask)
 {
     if (!_mask.IsValidMask())
     {
         throw new SubnetErrorException("不是正确的掩码格式");
     }
     if (_ip.GetSubnetAddress(_mask).CompareTo(_ip) != 0)
     {
         throw new SubnetErrorException("子网地址和掩码不搭配");
     }
     ip          = _ip;
     mask        = _mask;
     maskBitsNum = _mask.GetMaskBits();
 }