Populate ASP.NET dropdown list with month names using LINQ

Using LINQ and the Enumerable.Range method it's possible to populate a dropdown list of month names in a single line.

    Enumerable.Range(1, 12)
    .Select(x => new ListItem { 
        Text = new DateTimeFormatInfo().GetAbbreviatedMonthName(x), 
        Value = x.ToString() 


Subscribe or Follow Me For Updates

Subscribe to my YouTube channel or follow me on Twitter or GitHub to be notified when I post new content.