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
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);