views:

62

answers:

2

I've found a ton of tutorials, however they are all very old for 1.1 or 2.0; there must be an easier way now with .NET 3.5.

Care to share? :)

+1  A: 

Nothing has changed; the old way is still the only way to do it.

SLaks
A: 
//To get a host with a www address
IPHostEntry ip = Dns.GetHostByName ("www.vbcity.com");
IPAddress [] IpA = ipE.AddressList;
for (int i = 0; i < IpA.Length; i++)
{
    Console.WriteLine ("IP Address {0}: {1} ", i, IpA[i].ToString ());
}

//To get the local IP address
string sHostName = Dns.GetHostName ();
IPHostEntry ipE = Dns.GetHostByName (sHostName);
IPAddress [] IpA = ipE.AddressList;
for (int i = 0; i < IpA.Length; i++)
{
    Console.WriteLine ("IP Address {0}: {1} ", i, IpA[i].ToString ());
}

Sources:

  • devcity.net/Articles/62/1/gethostbyname.aspx

To verify you ip address you can try ip address