【发布时间】:2013-05-04 15:23:02
【问题描述】:
代码:
string sURL = "http://subdomain.website.com/index.htm";
MessageBox.Show(new System.Uri(sURL).Host);
给我“subdomain.website.com”
但我需要主域“website.com”作为任何 url 或 web 链接。
我该怎么做?
【问题讨论】:
-
其实你想要顶级域名。 subdomain.website.com 是域,website.com 是顶级域。
-
这确实不是一个很难解析的字符串。你试过
.Split和string.Join的简单组合吗? -
@ysrb ,顶级域是 com,而不是 website.com。