使用以下代码,我得到了一个很好的格式化字符串:
Request.QueryString.ToString
给了我类似的东西:&hello=worldµsoft=sucks
但是,当我使用此代码将集合克隆到另一个对象(相同类型)时,我会从 ToString() 方法中取回 Type()。
System.Collections.Specialized.NameValueCollection variables = new System.Collections.Specialized.NameValueCollection(Request.QueryString);
if (!string.IsNullOrEmpty(variables["sid"]))
variables.Remove("sid");
Response.Write(variables.ToString());
有没有一种更整洁的方式来输出它而不是手动查找和构建字符串?