日期:2014-05-20 浏览次数:20800 次
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!