按属性c#排序对象列表
发布时间:2020-12-15 04:35:45 所属栏目:百科 来源:网络整理
导读:我有这门课: public class Leg{ public int Day { get; set; } public int Hour { get; set; } public int Min { get; set; }} 我有一个获取腿列表的函数,称为GetLegs() ListLeg legs = GetLegs(); 现在我想对此列表进行排序.所以我首先要考虑的是日,然后是
我有这门课:
public class Leg { public int Day { get; set; } public int Hour { get; set; } public int Min { get; set; } } 我有一个获取腿列表的函数,称为GetLegs() List<Leg> legs = GetLegs(); 现在我想对此列表进行排序.所以我首先要考虑的是日,然后是小时,最后是分钟. 谢谢 解决方法
也许是这样的:
List<Leg> legs = GetLegs() .OrderBy(o=>o.Day) .ThenBy(o=>o.Hour) .ThenBy(o=>o.Min).ToList(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |