IPv4 to Integer C#


        
///   <summary>
        
///  将IP地址转换为Uint
        
///   </summary>
        
///   <param name="ipString"></param>
        
///   <returns></returns>
         public   static   uint  ToInt( string  ipString)
        {
            
return  BitConverter.ToUInt32(System.Net.IPAddress.Parse(ipString).GetAddressBytes(),  0 );
        }

        
///   <summary>
        
///  将Uint转换为IP地址
        
///   </summary>
        
///   <param name="address"></param>
        
///   <returns></returns>
         public   static   string  ToString( uint  address)
        {
            
return   new  System.Net.IPAddress(address).ToString(); 
        }

 

IPv4地址与int之间的转换。 

你可能感兴趣的:(IPv4 to Integer C#)