Get IP Version 4 Address of the host

by 11:35 PM 0 comments

            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            //string MyIp = localIPs[localIPs.Length - 2].ToString();
            string MyIp = "";
            for (int i = 0; i < localIPs.Length; i++)
            {
                if (localIPs[i].AddressFamily == AddressFamily.InterNetwork)
                {
                    MyIp = localIPs[i].ToString();
                }
            }
            return MyIp;

ravi tuwar

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 comments:

Post a Comment