【发布时间】:2012-05-18 09:13:42
【问题描述】:
这是我的尝试
public MyClass
{
public Guid ID {set; get;}
public DateTime CreatedDateTime {set; get;}
}
ConcurrentDictionary<Guid, MyClass> dic = new ConcurrentDictionary<Guid,MyClass>();
我试试这个,但我遇到了一些麻烦......
dic.OrderBy(i=>i.Value.CreatedDateTime);
我遇到了类似的错误
Cannot implicitly convert type 'System.Linq.IOrderedEnumerable'
有什么线索吗?谢谢!!
【问题讨论】:
-
对字典进行排序真的没有意义......值不是这样存储的
-
@Muad'Dib 那么我该如何对这个字典进行排序呢?你能帮忙吗?
-
dictionary 没有实现 IOrderdEnumerable,所以你不能在它上面使用 OrderBy()。字典中的项目是按任意顺序存储的,没有“第一个”元素和“最后一个”元素的概念,所以你不能真正对它进行排序
标签: c# .net datetime sorting dictionary