我有一个通用列表......
public List
ApprovalEventDto有
public class ApprovalEventDto { public string Event { get; set; } public DateTime EventDate { get; set; } }
如何按活动日期对列表进行排序?
您可以使用List.Sort(),如下所示:
ApprovalEvents.Sort((lhs, rhs) => (lhs.EventDate.CompareTo(rhs.EventDate)));
using System.Linq; void Listsort(List list) { return list.OrderBy(x => x.EventDate).ToList(); }