Get IP address from host name : DNS : Network C# Examples


C# Examples » Network » DNS »

 

Get IP address from host name









    
using  System;
using  System.Net;

class  MainClass
{
        public  static  void  Main()
        {
                IPHostEntry  ihe  =  Dns.GetHostByName(Dns.GetHostName());
            IPAddress  myself  =  ihe.AddressList[0];

                Console.WriteLine(myself);
        }
}
    
   
  
   



Output

192.168.1.101


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» DNS