Given a URL as follows:
foo.bar.car.com.au
I need to extract foo.bar.
foo.bar
I came across the following code :
pr
private static string GetSubDomain(Uri url) { if (url.HostNameType == UriHostNameType.Dns) { string host = url.Host; String[] subDomains = host.Split('.'); return subDomains[0] + "." + subDomains[1]; } return null; }