Categories

Thousands of experts bid on your personal project at ScriptLance.com

Displays your IP address and hostname

This example will display your IP address and hostname using C#

using System;
using System.Net;
class MYDns
{
public static void Main ()
{
string hostName = Dns.GetHostName();
Console.WriteLine("Local hostname: {0}", hostName);
IPHostEntry myself = Dns.GetHostByName(hostName);
foreach (IPAddress address in myself.AddressList)
{
Console.WriteLine("IP Address: {0}", address.ToString());
}
}
}

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

You must be logged in to post a comment.