Isabell
asked on
Getting the Keys by the value in Dictionary
Hi,
I have a dictionary:
I used it as follow:
But this will return the first key only.
For example, if
How can I accomplish this?
I have a dictionary:
Dictionary<int, int> dict = new Dictionary<int, int>();
I want to get the key(s) that has the max value.I used it as follow:
var max = dict.FirstOrDefault(x=>x.Value==maxValue).Key;
But this will return the first key only.
For example, if
maxValue=5
and associated keys are 1 and 4, I want to print out both 1 and 4.How can I accomplish this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
E.g.
Open in new window