Tools Used : Visual C# .NETThe .Net DNS class can be used to get a host name or an IP of a given host name. To use DNS class in your project, you need to include System.NetInclude System.Net ReferenceAnd say I want to get IP address if www.mindcracker.com. The given code will do that for you.using System;using System.Net;namespace DNSName{/// <summary>/// Summary description for Class1./// </summary>class Class1{static void Main(string[] args){IPHostEntry ipEntry = Dns.GetHostByName (http://www.mindcracker.com/);IPAddress [] IpAddr = ipEntry.AddressList;for (int i = 0; i < IpAddr.Length; i++){Console.WriteLine ("IP Address {0}: {1} ", i, IpAddr[i].ToString ());}}}} Get Local System's host name and IPUse GetHostName with no parameter to return the host name of a local machine. Once you have host name, pass this host name as a parameter in GetHostByName. See above.string strHostName = Dns.GetHostName ();
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: