////// 将十进制IP转换成二进制IP /// /// IP字符串 public string ChangeIP(string strIP) { string strHtml = ""; string[] IParray = strIP.Split('.'); //拆分IP int IP1 = Convert.ToInt32(IParray[0]); int IP2 = Convert.ToInt32(IParray[1]); int IP3 = Convert.ToInt32(IParray[2]); int IP4 = Convert.ToInt32(IParray[3]); string strIP1 = GetIP(IP1); string strIP2 = GetIP(IP2); string strIP3 = GetIP(IP3); string strIP4 = GetIP(IP4); strHtml = strIP1 + strIP2 + strIP3 + strIP4; return strHtml; }返回值为2进制IP
////// 得到二进制IP /// /// 十进制型IP public string GetIP(int IP) { string strIP = Convert.ToString(IP,2); int len = strIP.Length; if(len<8) { for(int i=0;i<8-len;i++) { strIP = "0" + strIP; } } return strIP; }