Antonio Haley
Antonio Haley

Reputation: 4790

How do you resolve a domain name to an IP address with .NET/C#?

How do you resolve a domain name to an IP address with .NET/C#?

Upvotes: 30

Views: 6557

Answers (2)

Yaakov Ellis
Yaakov Ellis

Reputation: 41510

Try using the System.Net.Dns class

Upvotes: 1

lubos hasko
lubos hasko

Reputation: 25052

using System.Net;

foreach (IPAddress address in Dns.GetHostAddresses("www.google.com"))
{
   Console.WriteLine(address.ToString());
}

Upvotes: 20

Related Questions