using System.Diagnostics;
using System.Collections.Generic;
public static void Main()
Stopwatch stopwatch = Stopwatch.StartNew();
DateTime startDate = new DateTime(1,01,01);
DateTime endDate = new DateTime(9999, 12, 31);
DateTime loopDate = startDate;
var totalMonths = ((endDate.Year - startDate.Year) * 12) + endDate.Month - startDate.Month;
loopDate = new DateTime(startDate.Year, startDate.Month, 1).AddMonths(1);
List<DateTime> firstDayOfMonth = Enumerable.Range(0, totalMonths)
.Select(i => loopDate.AddMonths(i))
firstDayOfMonth.Add(new DateTime(endDate.Year,endDate.Month, 1));
Console.WriteLine("Found dates: {0} in {1} milliseconds", firstDayOfMonth.Count, stopwatch.ElapsedMilliseconds);