In the internet there are several places that show you how to get an IP address. And a lot of them look like this example:
String strHostName = string.Empty;
Updating Mrchief's answer with Linq, we will have:
public static IPAddress GetLocalIPAddress() { var host = Dns.GetHostEntry(Dns.GetHostName()); var ipAddress= host.AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); return ipAddress; }