The specific method is as follows:
private void btnChenk_Click (object sender, System.EventArgs e) {System.Net.IPAddress [] addressList = Dns.GetHostByName (Dns.GetHostName ()) AddressList;. if (addressList.Length> 1) {nativeIP.Text = addressList [ 0] .tostring (); serverip.text = addressList [1] .tostring (); else {nativeip.text = addresslist [0] .tostring (); serverip.text = "Break the line ..."; }
Usually the list of addressList [] is the current IP address;
If it is currently a dial-up Internet, addresslist [0] .tostring () is
Local IP address; addresslist [1] .tostring () is the online address.
If you are currently using [Enternet 300], addressList [1] .tostring ()
It is a local IP address; addressList [0] .tostring () is the online address.
If the program can only detect only one IP address, it proves that the current
The computer is not online!