Select your language

This CSharp (C#) code snippet shows how to get the IP address of the machine.

 

private void ListIPAddresses()
{
    IPHostEntry myIPHostEntry = Dns.GetHostEntry(Dns.GetHostName());

    foreach (IPAddress myIPAddress in myIPHostEntry.AddressList)
    {
        Console.WriteLine(myIPAddress.ToString());    
    }
}