Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:44:23+00:00 2026-05-27T16:44:23+00:00

Looking for linq query to fill a list with month + year for example

  • 0

Looking for linq query to fill a list with month + year for example (January 2012)

starting form current month

   var currentdate = System.DateTime.Now

If Dec 2011 is the current month
then list should be like this

December 2011
January 2012
……
November 2012

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:44:24+00:00Added an answer on May 27, 2026 at 4:44 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to perform a query on an example list of objects Date
I'm looking into LINQ and the query language appears (at least on the surface)
I am looking for a way in LINQ to match the follow SQL Query.
LINQ gurus, I am looking for help to write a query... I have a
I am looking for linq query to see if there exists a similar object
I am looking for a linq to Xdoc query to group by a subset
I am looking for a nice simple LINQ query that can get an item
I was looking at a co-workers Linq query, shown below (the query executes correctly):
I am looking to optimize my LINQ query because although it works right, the
I am looking to learn Linq to query MS SQL databases, but am unsure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.