Wednesday, June 10, 2009

How to get the host name and IP address of local machine using C#.

How to get the host name and IP address of local machine using C#?Here is a example to get host name and IP address of local machine.
CODE:
1 : using System.Net;
2 : string strHostName = Dns.GetHostName();
3 : IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
4 : IPAddress[] ipAddress= ipEntry.AddressList;
5 : MessageBox.Show("Local machine host name="+strHostName.ToString());
6 : MessageBox.Show("IP address="+ipAddress[0].ToString());

1 comment:

  1. Hai,
    Thanks for Your information.I found my internet ip address by the site www.ip-details.com.But From this Artile I knew how to find localmachine ip address.

    ReplyDelete