The problem is that there is a very large lists of "pseudo top-level domains", such as co.uk, wakayama.jp or edu.cn, or even "top-level domains" with three parts. There is no built in list for all of them in C#, so the best solution that I can see is to specify the ones that you expect and separate on them, as of below:
List<string> parts = null;
Uri uri = new Uri("http://www.xx.yy.co.uk/folder/whatever.html");
string s = uri.Host;
string[] twoLevelDomains = { "co.uk", "edu.cn" };
foreach(var twoLevelDomain in twoLevelDomains)
{
if (s.EndsWith(twoLevelDomain))
{
parts = s.Replace("." + twoLevelDomain, "").Split('.').ToList();
parts.Add(twoLevelDomain);
}
}
if(parts == null) {
parts = s.Split('.').ToList();
}
Background:
The only official top-level domains are just one part, such as .uk. A somewhat comprehensive list of all the "pseudo top-level domains" is available here: https://wiki.mozilla.org/TLD_List . While it is a big list, it is still does not seem comprehensive, since many countries are listed with just 1 top domain and there are fields such as "(others ?)".