fork(14) download
  1. using System;
  2. using System.Linq;
  3. using System.Globalization;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9.  
  10. var today = DateTime.Today;
  11. var beforeMonths = Enumerable.Range(1, 12)
  12. .Where(i => i < today.Month)
  13. .Select(i => new DateTime(today.Year, i, 1))
  14. .ToList();
  15.  
  16. foreach(var dt in beforeMonths)
  17. Console.WriteLine(dt.ToString());
  18. }
  19. }
Success #stdin #stdout 0.05s 33984KB
stdin
Standard input is empty
stdout
1/1/2013 12:00:00 AM
2/1/2013 12:00:00 AM