Csharp/C Sharp by API/System.Net/IPHostEntry
IPHostEntry.AddressList
using System;
using System.Net;
class MainClass
{
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());
}
}
}
IPHostEntry.Aliases
using System;
using System.Net;
class MainClass
{
public static void Main(string[] argv)
{
IPAddress test = IPAddress.Parse("64.200.123.1");
IPHostEntry iphe = Dns.GetHostByAddress(test);
foreach(string alias in iphe.Aliases)
{
Console.WriteLine("Alias: {0}", alias);
}
}
}
IPHostEntry.HostName
using System;
using System.Net;
class MainClass
{
public static void Main(string[] argv)
{
IPAddress test = IPAddress.Parse("64.200.123.1");
IPHostEntry iphe = Dns.GetHostByAddress(test);
Console.WriteLine("Information for {0}", test.ToString());
Console.WriteLine("Host name: {0}", iphe.HostName);
}
}