Gets the full qualified domain name from the local machine (localhost) in CSharp.

public static string GetLocalhostFqdn()
{
    var ipProperties = IPGlobalProperties.GetIPGlobalProperties();
    return string.IsNullOrWhiteSpace(ipProperties.DomainName) ?
        ipProperties.HostName : string.Format("{0}.{1}", ipProperties.HostName,
            ipProperties.DomainName);
}