在乌里更换主机主机

由网友(恶魔的『信)分享简介:什么是更换乌里使用.NET的主机部分的最好方法是什么?What is the nicest way of replacing the host-part of an Uri using .NET?即:string ReplaceHost(string original, string newHostName);...

什么是更换乌里使用.NET的主机部分的最好方法是什么?

What is the nicest way of replacing the host-part of an Uri using .NET?

即:

string ReplaceHost(string original, string newHostName);
//...
string s = ReplaceHost("http://oldhostname/index.html", "newhostname");
Assert.AreEqual("http://newhostname/index.html", s);
//...
string s = ReplaceHost("http://user:pass@oldhostname/index.html", "newhostname");
Assert.AreEqual("http://user:pass@newhostname/index.html", s);
//...
string s = ReplaceHost("ftp://user:pass@oldhostname", "newhostname");
Assert.AreEqual("ftp://user:pass@newhostname", s);
//etc.

的System.Uri似乎并没有多大帮助。

System.Uri does not seem to help much.

推荐答案

System.UriBuilder 是你以后有什么...

System.UriBuilder is what you are after...

阅读全文

相关推荐

最新文章