C#实现按月循环
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;
}
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;
}