Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,
I have a list which has following value
Brand           Count
B1               2
B2               3
B3               3

now i want to get second max value in count as answer is

2

Please provide linq query. Note brands and counts are decided at runtime
Posted
Updated 9-Mar-14 23:25pm
v2

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
C#
var DataCount= TableName
    .OrderByDescending(e => e.Count)
    .Skip(1)
    .First();


second highest..../a>[^]
 
Share this answer
 
v4
Comments
Aravindba 10-Mar-14 5:57am    
hi can u tell me what u update in my solution ?
http://www.codeproject.com/Questions/741590/get-masterpage-textbox-value-in-childpage
Nirav Prabtani 11-Mar-14 3:07am    
hello..i have scripted ir into C# language instead of normal html text.. :)
try below script

int secondHighest = (from Count in test
                             orderby Count descending
                             select Count).Distinct().Skip(1).First()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900