I have Dictionary<int key, int sum>
. I need select all keys where sum==1
.
How I could do it with LINQ ?
I have Dictionary<int key, int sum>
. I need select all keys where sum==1
.
How I could do it with LINQ ?
Put Where
to filter out key-value pairs by values and Select
to narrow down key-value pairs to keys:
var keys = myDictionary
.Where(pair => pair.Value == 1)
.Select(pair => pair.Key)
.ToArray(); // if you want an array of these keys