C# Get the ip address of a host name

Often times you want to find the ip address of a host name. This function will do this for you. It returns the first address.

using System.Net;

public string GetIPAddress(string sHostName)
   IPHostEntry ipEntry = Dns.GetHostByName(sHostName);
   IPAddress [] addr = ipEntry.AddressList;
   string sIPAddress = addr[0].ToString();

   return sIPAddress;



Popular posts from this blog

C# Form Application in Kiosk Mode/Fullscreen

C# using a transaction with ODBC

Notify Icon Text vs BalloonTipText