通过 linq 获取最大项

Get top max item by linq

考虑:

public class student
{
public int Avd{get;set;}
}

主要是:

list<student> Students =new List<student>{2,3,6,1,20,12,45};

我想通过 linq 获得学生中前 5 名的最大 AVG。我该怎么做?

根据 Avg 降序 顺序对列表进行排序,然后使用 Take 得到 5 个学生:

Students.OrderByDescending(s => s.Avg).Take(5);
Students = Students.OrderByDescending(x=>x.Avd).Take(5).ToList();