class DateSerial
{
public DateTime Date;
public int Serial;
public DateSerial(DateTime date)
{
Date = date;
Serial = 0;
}
public override string ToString()
{
return string.Format("{0} {1}", Date.ToString("yyyy-MM-hh"), Serial);
}
}
static void Sort(List<DateSerial> dateList)
{
DateTime minDate = new DateTime(0);
for (int i = 0; i < dateList.Count; i++)
{
DateTime tempDate = DateTime.Parse("2099-1-1");
for (int j = 0; j < dateList.Count; j++)
{
if (dateList[j].Date > minDate)
{
dateList[j].Serial++;
tempDate = dateList[j].Date < tempDate ? dateList[j].Date : tempDate;
}
}
minDate = tempDate;
}
}
static void Main(string[] args)
{
List<DateSerial> dateList = new List<DateSerial>();
dateList.Add(new DateSerial(DateTime.Parse("2009-03-01")));
dateList.Add(new DateSerial(DateTime.Parse("2008-06-12")));
dateList.Add(new DateSerial(DateTime.Parse("2009-01-12")));
dateList.Add(new DateSerial(DateTime.Parse("2008-06-12")));
dateList.Add(new DateSerial(DateTime.Parse("2007-06-14")));
dateList.Add(new DateSerial(DateTime.Parse("2008-09-18")));
dateList.Add(new DateSerial(DateTime.Parse("2004-01-12")));
Sort(dateList);
foreach (DateSerial d in dateList)
{
Console.WriteLine(d);
}
Console.ReadLine();
}
你可以把日期和序号都写在数据库里面嘛
然后用DataGrid绑定,
再显示出来,也是一个办法。
不好意思,没看懂
楼主的意思是相同的日期序列号是一样的,按照日期重小到大排
你在数据里排好序生成一个ROWMBER ,再把数据绑定到控件上