Finding IP Address information of your computer in C#

The below code will be useful in finding IP address of your local computer.
Please include System.Net directory.

using System;
using System.Net;

public class ForgetCode
{
    public static void Main()
    {
        UseDNS();
    }

    public static void UseDNS()
    {
        string hostName = Dns.GetHostName();
        Console.WriteLine("Host Name = " + hostName);
        IPHostEntry local = Dns.GetHostByName(hostName);
        foreach (IPAddress ipaddress in local.AddressList)
        {
            Console.WriteLine("IPAddress = " + ipaddress.ToString());
        }
    }
}

Output:
Host Name = Your-PC Name
IPAddress = Your IP address