Convert an IOrderedEnumerable> into a Dictionary

后端 未结 3 568
花落未央
花落未央 2020-12-29 19:07

I was following the answer to another question, and I got:

// itemCounter is a Dictionary, and I only want to keep
// key/value pairs with         


        
3条回答
  •  时光取名叫无心
    2020-12-29 19:50

    The question is too old but still would like to give answer for reference:

    itemCounter = itemCounter.Take(maxAllowed).OrderByDescending(i => i.Value).ToDictionary(i => i.Key, i => i.Value);
    

提交回复
热议问题