3
我試圖解析string Response
成NameValueCollection
如下所示:必須使用http:// 1 /?在新的URI()爲了得到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
是扔沒有它)。
有沒有不同的方法我應該接近這個?
這很好,謝謝! – 2013-04-10 23:08:07