Reputation: 971
I have a dictionary declared as following:
Dictionary<Tuple<long, long>, Tuple<double, long>> dict= new Dictionary<Tuple<long, long>, Tuple<double, long>>();
How do I get the max value of Item2 of all dictionary values?
Upvotes: 0
Views: 3245
Reputation: 2218
You can use the Max method. Not entirely clear which one of these you're asking for:
var maxKey = dict.Max(x => x.Key.Item2);
var maxValue = dict.Max(x => x.Value.Item2);
var maxEither = Math.Max(dict.Max(x => x.Key.Item2), dict.Max(x => x.Value.Item2));
Upvotes: 3
Reputation: 27861
You can simply use the Max
LINQ method like this:
long max = dict.Values.Max(x => x.Item2);
Upvotes: 3