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;
  }

转载于:https://www.cnblogs.com/jinmingjie/archive/2012/06/21/2557683.html

你可能感兴趣的:(c#)