How To Get IP Address From The Host Name
September 3rd, 2007 | by programming |Use the following method to get IP address of the hostname:
using System.Net; public string GetIPAddress(string sHostName) { IPHostEntry ipEntry = Dns.GetHostByName(sHostName); IPAddress [] addr = ipEntry.AddressList; string sIPAddress = addr[0].ToString(); return sIPAddress; }
By Ballu on Jul 22, 2008 | Reply
hi ,
Will IPAddr.AddressList[0].ToString() always have the right IP?
If i run this code, will i get the right IP at index 0.
Can you please reply me ASAP?
Thanks!