Get the ip address

Description :


This code shows how to Get the ip address


namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
foreach (string computername in args)
{
try
{
IPAddress[] IPaddresses = Dns.GetHostEntry(computername).AddressList;
foreach (IPAddress Myaddress in IPaddresses)
{
Console.WriteLine("{0} = {1} ({2})",
computername, Myaddress, Myaddress.AddressFamily);
}
}
catch (Exception ex)
{
Console.WriteLine("{0} = Error ({1})", computername, ex.Message);
}
}
}
}


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: