【发布时间】:2012-12-02 11:03:36
【问题描述】:
使用下面的代码,我得到了这个错误,需要帮助如何让方法 Load 返回List<B>
不能将 System.Collections.Generic.IEnumerable 类型隐式转换为 System.Collections.Generic.List
public class A
{
public List<B> Load(Collection coll)
{
List<B> list = from x in coll select new B {Prop1 = x.title, Prop2 = x.dept};
return list;
}
}
public class B
{
public string Prop1 {get;set;}
public string Prop2 {get;set;}
}
【问题讨论】:
-
必须是列表吗?请记住,这会实现查询。
标签: c# generics ienumerable