可能的重复:
使用预定义的排序值列表对对象进行排序 https://stackoverflow.com/questions/652337/sort-objects-using-predefined-list-of-sorted-values
C# 帮助:在 C# 中对对象列表进行排序 https://stackoverflow.com/questions/925471/c-help-sorting-a-list-of-objects-in-c
双柱
对 C# 中的对象列表进行排序 https://stackoverflow.com/questions/925471/c-help-sorting-a-list-of-objects-in-c/925477#925477
public class CarSpecs
{
public CarSpecs()
{
}
private String _CarName;
public String CarName
{
get { return _CarName; }
set { _CarName = value; }
}
private String _CarMaker;
public String CarMaker
{
get { return _CarMaker;}
set { _CarMaker = value; }
}
private DateTime _CreationDate;
public DateTime CreationDate
{
get { return _CreationDate; }
set { _CreationDate = value; }
}
}
这是一个列表,我正在尝试找出一种有效的方法来对该列表进行排序List<CarSpecs> CarList
,包含 6 辆(或任何整数)汽车,按汽车制造日期。我本来打算进行冒泡排序,但这行得通吗?有帮助吗?
Thanks
CarList = CarList.OrderBy( x => x.CreationDate ).ToList();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)