C#对List数组的排序问题——根据某一个字段进行排序

正序

List<T> sorted = students.OrderBy(s => s.num).ToList();//按照姓名排序

倒序

List<T> sorted = students.OrderByDescending(s => s.age).ToList();//按照年龄排序

猜你喜欢

转载自blog.csdn.net/qq_20799821/article/details/115117286