با این کد میتونید IP یه هاست رو بدست بیارید (مثل همون ping خودمونه :smilingsmiley:)
using System;
//softafzar.net
// using the System.Net namespace
using System.Net;
class Class1
{
[STAThread]
static void Main(string[] args)
{
// Request the name
Console.Write("Please type the name of the host: ");
// Store it in 'host'
string host = Console.ReadLine();
try
{
// Get the DNS information
IPHostEntry ipHost = Dns.GetHostByName(host);
// Display the host name
Console.WriteLine("Host name: {0}", ipHost.HostName);
// Store the list of IP adresses
IPAddress[] ipAddr = ipHost.AddressList;
// Loop to actually display the IP
for(int x = 0; x < ipAddr.Length; x++)
{
Console.WriteLine("IP address: {0}", ipAddr[x].ToString());
}
}
// Catch the exception (if host was not found)
catch(System.Net.Sockets.SocketException)
{
Console.WriteLine("Host not found.");
}
}
}