I have created a dictionary (differentKeys
). For getting top 2 elements I am using below code.
topKeys[B] = (from entry in differentKeys orderby entry.Value descending
select entry)
.ToDictionary(pair => pair.Key, pair => pair.Value).Take(2)
.ToDictionary(x=>x.Key,x=>x.Value).Values.ToArray();
But it seems not giving expected outcome. Can you please suggest line in C# which will return me top 2 maximum elements?