📜  内置方法来排序列表 c# 代码示例

📅  最后修改于: 2022-03-11 14:49:02.039000             🧑  作者: Mango

代码示例1
using System.Linq;
//This list contains OrderDate, OrderID, Quantity, Total properties
List objListOrder = new List(); 
//How to GetOrderList(objListOrder)?
//Answer:
//- Ascending order
List SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
//- Descending order
List SortedList = objListOrder.OrderByDescending(o=>o.OrderDate).ToList();