// using System.Web; var qs1 = HttpUtility.ParseQueryString("id=5&type=1"); qs1.ToString(); // "id=5&type=1" var qs2 = HttpUtility.ParseQueryString(String.Empty); qs2["id"] = "11"; qs2["name"] = "Tom"; qs2.ToString(); // "id=11&name=Tom"
HttpValueCollection 的簽名
[Serializable] internal class HttpValueCollection : NameValueCollection { }
ParseQueryString 的簽名
public static NameValueCollection ParseQueryString(string query, Encoding encoding) { if (query == null) { throw new ArgumentNullException("query"); } if (encoding == null) { throw new ArgumentNullException("encoding"); } if ((query.Length > 0) && (query[0] == '?')) { query = query.Substring(1); } return new HttpValueCollection(query, false, true, encoding); }
0 回應:
張貼留言