Monday, 19 August 2013

Your computer might have more than one IP addresses. So in order to find all the IP Address of your computer, use the following code.

Note This code will find the IPv4 addresses  

Download as Visual Studio 2012 Project

using System;
using System.Net;

namespace MyIPAddress
    class Program
        static void Main(string[] args)
            IPHostEntry host;
            string localIP = "?";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
                if (ip.AddressFamily.ToString() == "InterNetwork")
                    localIP = ip.ToString();

See Also
How to find the IP Addess of Computer using Java

Get Ebooks delivered to your email id


Subscribe to our channel


Powered by Blogger.

Home | Contact Us | DMCA | Terms of Service | Privacy | Advertise

Maven Scientists