Linq能用来查询自定义点类吗 如Cpeople
如题,代码是这样写的,但是提示为找到类中Orderby的实现
public class CPeople : DictionaryBase, ICloneable { public new IEnumerator GetEnumerator() { foreach (object person in Dictionary.Values) yield return (CPerson)person; } } CPeople pl; IEnumerable<CPerson> sortedPeple = from CPerson in pl orderby CPerson.Name.Length, CPerson.Name select CPerson; foreach (CPerson person in sortedPeple) { ListViewItem item = listView.Items.Add(person.Name); item.SubItems.Add(person.Age.ToString()); }public new
[解决办法]
参考:
http://blog.csdn.net/q107770540/article/details/6010387
[解决办法]
另外,还要实现这个INTERFACE。或者
IEnumerable<CPerson> sortedPeple =
from CPerson x in pl
orderby x.Name.Length, x.Name
select x;
也行。问题是因为IEnumerable.current只返回object, 编译器无法确定x的类型
[解决办法]如需要阅读该回复,请登录或注册CSDN!