Search code examples
c#dictionaryplinq

a specific plinq query


i want to select one id that have max value in a C# dictionary<int, double>

for example

initial dictionary

 1   0.8   
 2   0.78   
 3   0.9   
 4   0.87   

after select

 3   0.9   

my current code

dic.AsParallel().Max(x => x.Value);

Solution

  • dic.AsParallel().First(y => y.Value == dic.Select(x => x.Value).Select(x => x.Max())).Key