It's available from NuGet:
PM> Install-Package ARSoft.Tools.Net
Import the namespace:
using ARSoft.Tools.Net.Dns;
Then making a synchronous lookup is as simple as:
var response = DnsClient.Default.Resolve("gmail.com", RecordType.Mx);
var records = response.AnswerRecords.OfType<MxRecord>();
foreach (var record in records) {
Console.WriteLine(record.ExchangeDomainName);
}
Which gives us the output:
alt3.gmail-smtp-in.l.google.com
alt4.gmail-smtp-in.l.google.com
gmail-smtp-in.l.google.com
alt1.gmail-smtp-in.l.google.com
alt2.gmail-smtp-in.l.google.com