Reputation: 83
consider:
public class student
{
public int Avd{get;set;}
}
and in main :
list<student> Students =new List<student>{2,3,6,1,20,12,45};
I want get top 5 max AVG in Students by linq . how can i do this?
Upvotes: 0
Views: 290
Reputation: 101681
Sort the list based on Avg
in descending order then use Take
to get 5 students:
Students.OrderByDescending(s => s.Avg).Take(5);
Upvotes: 0