Private voidButton1_Click (Objectsender, EventArgs e) { stringStartIP =""; stringEndIP =""; StartIP=Startinput.text; EndIP=Endinput.text; UINTIstartip =Iptint (StartIP); UINTIendip =Iptint (ENDIP); //string ip_result= ""; StringBuilder ip_result=NewStringBuilder (); if(Iendip >=Istartip) { for(UINTip = istartip; IP <= iendip; ip++) {Ip_result. Append (Inttip (IP)). Append ("\ r \ n"); //Ip_result = ip_result + inttip (IP) + "\ r \ n"; } resulttextbox.text= Ip_result. ToString ();//RichTextBox } Else{MessageBox.Show ("God, the starting IP is actually bigger than terminating the IP."); } } Public Static UINTIptint (stringipstr) { string[] IP = ipstr.split ('.'); UINTIpcode =0xffffff00|byte. Parse (ip[3]); Ipcode= Ipcode &0xffff00ff| (UINT. Parse (ip[2]) <<0x8); Ipcode= Ipcode &0xff00ffff| (UINT. Parse (ip[1]) <<0xF); Ipcode= Ipcode &0x00ffffff| (UINT. Parse (ip[0]) <<0x18); returnIpcode; } Public Static stringInttip (UINTIpcode) { byteA = (byte) ((Ipcode &0xff000000) >>0x18); byteB = (byte) ((Ipcode &0x00ff0000) >>0xF); bytec = (byte) ((Ipcode &0x0000FF00) >>0x8); byteD = (byte) (Ipcode &0x000000ff); stringIpstr =string. Format ("{0}. {1}. {2}. {3}", A, B, C, D); returnIpstr; }
C # Specifies IP segment generation IP address