-1

I have a dictionary which is
ConcurrentDictionary<uint, Mensaje> mensajesEnviados = new ConcurrentDictionary<uint, Mensaje>();

I want to retrieve all the objects Mensaje whose key value is less than a certain value, to iterate on them. How should I do that?

Thanks in advance!

asCii88
  • 23
  • 6
  • What have you tried? `ConcurrentDictionary` is enumerable; have you tried simply enumerating it, filtering on elements with the key value as you want? Please provide [a good, _minimal_, _complete_ code example](http://stackoverflow.com/help/mcve) that shows clearly what you've tried. Explain what that code does and how that's different from what you want. – Peter Duniho Nov 12 '15 at 23:31
  • I had tried exactly what is on the answer below. I was missing the Select part. – asCii88 Nov 13 '15 at 00:47

1 Answers1

1

Try this:

var value = 42u; //your certain value
foreach (var m in mensajesEnviados.Where(kvp => kvp.Key < value).Select(kvp => kvp.Value))
{
}
Enigmativity
  • 113,464
  • 11
  • 89
  • 172