08-31-2010, 12:38 PM
This one is very simple. Everybody should now how to do this.
Imports:
Code:
Usage:
Imports:
Code:
using System.Net;
Code:
Code:
static string DNStoIP(string DNS)
{
try
{
IPHostEntry DNSHosts = Dns.GetHostEntry(DNS);
IPAddress[] DNSIPs = DNSHosts.AddressList;
return Convert.ToString(DNSIPs[0]);
}
catch (Exception ex)
{
throw ex;
}
Usage:
Code:
Console.WriteLine(DNStoIP("google.com"));