解决方案 »
- picturebox的透明部分于背景图片相同
- Calendar1的日期转换
- 在C#和C++语言中,操作符被看作是函数
- C#实现gridview批量导入excel验证重复(急急急)
- 割脉咬舌跪求(VS2005如何生成DLL文件)
- 调试时,提示"无法开始调试,无法找到Microsoft Internet Explorer"
- 求自动下载xml feeds 然后存到sql2005中的代码。 谢谢
- 过于ArrayList取值的问题
- 怎么求正态分布的随机变量
- 能否用DllImport调用一个exe文件?谢谢!
- html做页面 通过Ajax传值 C#后台处理后,C#后台应该怎么传值回html的页面
- 调用AxWebBrowser时,出现错误
StringBuilder sbList = new StringBuilder();
for (int i = 0; i < this.Count; i++)
{
if (i == 0)
{
sbList.AppendFormat("{0}={1}", this.GetKey(i), this.Get(i));
}
else
{
sbList.AppendFormat("&{0}={1}", this.GetKey(i), this.Get(i));
}
}你是在拼接url吧
object[] var = { 1, "1" };
StringBuilder sbList = new StringBuilder();
sbList.AppendFormat("{0}={1}", var);
string str = sbList.ToString();这样,没问题的,2楼说,调试试一下,看看
for (int i = 0; i < 10; i++)
{
object[] var = { i, i*10 };
if (i == 0) sbList.AppendFormat("{0}={1}", var);
else sbList.AppendFormat("&{0}={1}", var);
}这样可以测试通过 vs2010
using System;
using System.Text;
using System.Globalization;
using System.Collections.Specialized;namespace abc
{
public class test : NameValueCollection
{
public test() { } public string this[string name, int index] { get { return this.Get(index); } set { this.BaseAdd(name, value); } } public void Add(string name, string value, int index)
{
this[name, index] = value;
} public void Decode(string str)
{
this.Clear();
string[] a = str.Split('&'); //这里也是报同样错误
for (int i = 0; i < a.Length; i++)
{
string[] item=a[i].Split('=');
if (item.Length > 1)
{
this.Add(item[0], item[1], i);
}
}
} public string Encode()
{
if (this.Count < 1) return null;
StringBuilder sbList = new StringBuilder();
for (int i = 0; i < this.Count; i++)
{
object[] var = { this.GetKey(i), this.Get(i) }; //这里也是报同样错误
if (i == 0) sbList.AppendFormat("{0}={1}", var);
else sbList.AppendFormat("&{0}={1}", var);
}
return sbList.ToString(); //string str = "";
//for (int i = 0; i < this.Count; i++)
//{
// if (i == 0) str += this.GetKey(i) + "=" + this.Get(i); //这里也是报同样错误
// else str += "&" + this.GetKey(i) + "=" + this.Get(i);
//}
//return str;
} public void Remove(string arrayName, int index)
{
base.Remove(this[arrayName,index]);
}
}
}
是不是引用NameValueCollection类的问题呢?
{
if (this.Count < 1) return null;
//StringBuilder sbList = new StringBuilder();
String sbList = null;
string var0;
string var1;
NameValueCollection n = new NameValueCollection();
for (int i = 0; i < this.Count; i++)
{
//object[] var = { this.GetKey(i), this.Get(i) }; //这里也是报同样错误
var0 = n.GetKey(i);//{ this.GetKey(i), this.Get(i) };
var1 = n.Get(i);
if (i == 0)
{
sbList += string.Format("{0}={1}", n.GetKey(i), n.Get(i));
}
else
{
sbList += string.Format("&{0}={1}", var0, var1);
}
}
return sbList.ToString();
}