I am running a server, and I want to display my own IP address.
what is the syntax for getting the computer's own (if possible, external) IP address?
The guy before wrote this code
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
}
}
return localIP;
however, I generally distrust him, and I don't understand this code. Is there a better way to do so?