【发布时间】:2013-07-02 21:20:29
【问题描述】:
我正在尝试转换一组动态值,以便我可以使用 lambda 表达式来查询它们,但是在将集合转换为 IEnumerable 时我不断收到错误:
(IEnumerable<MyClass>ViewBag.MyClassList)
导致错误
Using the generic type System.Collections.Generic.IEnumerable<T> requires 1 type arguments
和
MyClass is a 'type', which is not valid in the given context
这实际上是零意义。 IEnumerable 想要一个类型,但使用的是 is not valid in the given context 类型。
停下来?
【问题讨论】:
-
可能是括号的问题。试试
((IEnumerable<MyClass>) ViewBag.MyClassList) -
那么您应该显示一些相关代码,以便我们也可以帮助您。
标签: asp.net-mvc collections types ienumerable