如何将带有对象的字典转换为该类型的列表?

时间:2012-01-20 20:29:19

标签: c# linq

如何将以下字典转换为频道对象列表?我尝试了ToList()方法,但我似乎无法让它工作。

List<Items> items = new List<Items>();

Dictionary<int, Items> foundItems = 
    statsCont.OrderByDescending(x => x.Value.NumberOfItems)
        .Take(10)
        as Dictionary<int, Items>;

2 个答案:

答案 0 :(得分:8)

你试过了吗?

foundItems.Values.ToList();

答案 1 :(得分:1)

怎么样:

List<Items> items = statsCont.OrderByDescending(x => x.Value.NumberOfItems)
    .Take(10)
    .Select(x => x.Value)
    .ToList();