1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| private void DeineLiebeMethode() { DateTime firstMonth = new DateTime(2013,10,01); DateTime thisMonth = DateTime.Now;
deineLiebeListBox.DataSource = GetListOfMonthes(firstMonth, thisMonth).Select(x => String.Format("{0:MMMM yyyy}", x)).ToList(); }
private IEnumerable<DateTime> GetListOfMonthes(DateTime start, DateTime end) { var month = new DateTime(start.Year, start.Month, 1, 0, 0, 0, start.Kind); var endMonth = new DateTime(end.Year, end.Month, 1, 0, 0, 0, end.Kind);
while (month <= endMonth) { yield return month; month = month.AddMonths(1); } } |