Getting System Information

Getting the Information about IP address of the system ,DNS name and NETbios names are really cool features provided by .net .Its very simple and really come handy for developers and an immemnse respite from hardcore network coding.

All you got to do is include the System.Net namespace and rest is as follows : -



using System.Net;



static void Main(string[] args)

{

//get the name of your system

Console.WriteLine("Name of the system is: {0}", DNS.GetHostName);



IPHostEntry Iplist = Dns.GetHostByName(host);


//IPHostEntry class provides a container class for intenet host //address information. It associates a Domain Name System (DNS) host name with an array of aliases and an array of matching IP addresses.



foreach (IPAddress ip in iplist.AddressList)

//.AddressList gets a list of IP addresses that are associated with a particular host.

{

Console.WriteLine("Your IP address is: " + ip.ToString());
}



//get the Nebios computer name

Console.WriteLine( NetBIOS: {0} ,System.Environment.MachineName);
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: