本文介绍了C#帮助:对C#中的对象列表排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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(或任何整数)汽车,由汽车制造日期。我打算做泡泡排序,但会工作吗?任何帮助?
This is a list and I am trying to figure out an efficient way to sort this list List<CarSpecs> CarList
, containing 6(or any integer amount) Cars, by the Car Make Date. I was going to do Bubble sort, but will that work? Any Help?
感谢
推荐答案
CarList = CarList.OrderBy( x => x.CreationDate ).ToList();
这篇关于C#帮助:对C#中的对象列表排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!