【发布时间】:2011-02-06 16:16:18
【问题描述】:
protected void Button2_Click(object sender, EventArgs e)
{
int[] L = { 1, 2, 3, 4, 5 };
ViewState["I"] = L.ToArray();
}
protected void Button1_Click(object sender, EventArgs e)
{
int[] I = { };
if (ViewState["I"] != null)
I = (int[])ViewState["I"];
for (int i = 0; i < I.Length; i++)
Response.Write(I[i].ToString());
}
当我运行程序时,出现错误:
无法转换类型的对象 'System.Collections.Generic.List`1[System.Int32]' 输入“System.Int32[]”。
为什么会出现这个错误?
【问题讨论】: