我正在尝试解析string Response
为NameValueCollection
如下所示:
public static NameValueCollection Request()
{
// Snipped irrelevant code, so here's the string I get:
string Response = "someparam=abcdef&another=123456";
return HttpUtility.ParseQueryString(
new Uri("http://1/?" + Response)
.Query);
}
NameValueCollection Request = SomeClass.Request();
string SomeParam = Request.Get("someparam");
string Another = Request.Get("another");
但是我必须指定似乎是“错误的” http://1/?
(UriFormatException
没有它就抛出a)。
我应该以不同的方式解决这个问题吗?