score:6

Accepted answer

i'm editing to turn my sample code into a method that i might almost use in production because it's more testable and culture-aware:

public ienumerable getmonths(datetime currentdate, iformatprovider provider)
{
    return from i in enumerable.range(0, 12)
           let now = currentdate.addmonths(i)
           select new
           {
               monthlabel = now.tostring("mmmm", provider),
               month = now.month,
               year = now.year
           };
}

this outputs (on a french computer):

linqpad output

score:8

var months = 
    enumerable.range(0, 12).
    select(n => datetime.today.addmonths(n)).
    select(d = new { year = d.year, month = d.month });

Related Query

More Query from same tag