I have a Dictionary and I want to find the key which has the highest value.
For example if I had
Key | Value
a | 1
b | 2
c | 3
I would want c to be returned.
I have this at the moment but it only searches for the highest value, I'm not sure how to return the key.
var max = occurrences.Max(x => x.Value);
var maxKey = occurrences.OrderByDescending(x => x.Value).First().Key;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With