1

I have a class:

public class Item
{
    public string ItemId { get; set; }
    public DateTime Created { get; set; }
    public string Title { get; set; }
}

If I have a List how can I group the items per year and then by month?

Of course for year would be something like:

list.GroupBy(t=>t.Created.Year);
user2818430
  • 5,195
  • 15
  • 63
  • 133

1 Answers1

2
 list.GroupBy(t => new { Year = t.Created.Year, Month = t.Created.Month });
Travis Sapp
  • 102
  • 1
  • 4