C#排序 转
本文链接:https://blog.csdn.net/fysuccess/article/details/36416255 C#中List<T>排序的两种方法 List<Student> stu = (List<Student>)Session["StudentList"]; Linq表达式: //按学号降序 List<Student> stuList = (from s instu orderby s.stuNOdescending select s).ToList<Student>(); //按学号升序 List<Student> stuList = (from s instu orderby s.stuNO select s).ToList<Student>(); 使用Lambda表达式排序: //按学号降序 单字段:List<Student> stuList= stu.OrderByDescending(s=> s.orderid).ToList<Student>(); 多字段:List<Student> stuList= stu.OrderByDescending(s=> new{s.stuNO,s.stuName}).ToList<Student>(); //按学号升序 单字段:List<Student> stuList= stu.OrderBy(s=> s.stuNO