一种方法:
DateTime start = DateTime.Parse("2007.9.1");
DateTime end = DateTime.Parse("2007.9.20");
while (start <= end)
{
richTextBox2.Text += start.ToShortDateString() + "\n";
start = start.AddDays(1);
}
另一种方法:
DateTime _BeginDate =DateTime.Parse("2006-07-01");
DateTime _EndDate = DateTime.Parse("2005-05-01");
DateTime _Date =_BeginDate;
while (true)
{
MessageBox.Show(_Date.ToString("yyyy-MM"));
_Date = _Date.AddMonths(1);
if (_Date.Year >= _EndDate.Year && _Date.Month > _EndDate.Month) break;
}