The follow ing code to display the current machine name and the ip address of the current machine
This is the console program, copy the below code and put inside your main method and include the following namespace.
using System.Net;
string strHostName="";
strHostName = Dns.GetHostName();
Console.WriteLine("Local Machine's Host Name: " + strHostName);
Console.ReadLine();
IPHostEntry ientry = Dns.GetHostByName(strHostName);
IPAddress[] addr = ientry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
}
Console.ReadLine();
Enjoy !!!
Subscribe to:
Post Comments (Atom)
Hai,
ReplyDeleteThanks for this code.I found my internet ip address in the site www.ip-details.com.From this code I get the Local machine name.Once again thanks.