【发布时间】:2014-03-27 17:05:44
【问题描述】:
我有一个会话对象,其中包含一个对象列表..
Session.Add("errorlist",errorlist);
现在我想在另一个函数中循环遍历这个错误列表。我试过了,但它给出了以下错误:
foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
这是我尝试过的:
var error = Session["errorlist"];
foreach (var item in error)
{
//Something here
}
我可以在“错误”变量中看到一个对象列表。
【问题讨论】:
-
Session和error的类型有哪些? -
errorlist的数据类型是什么?你是怎么声明的?
标签: c# list asp.net-mvc-4 session