I am trying to retrieve the month name and the year using LINQ from a list that has 2 properties without repeating the name of the months and the year.
public class Record
{
public int Id { get; set; }
public DateTime Date { get; set; }
}
DateTime d1 = new DateTime(2015, 1, 14);
DateTime d2 = new DateTime(2016, 3, 12);
DateTime d3 = new DateTime(2016, 4, 17);
DateTime d4 = new DateTime(2015, 5, 19);
DateTime d5 = new DateTime(2016, 6, 10);
List<Record> dates = new List<Record>
{
new Record { Id= 1, Date = d1 },
new Record { Id= 2, Date = d2 },
new Record { Id= 3, Date = d3 },
new Record { Id= 4, Date = d4 },
new Record { Id= 5, Date = d5 }
};
//Month should be in string format (January,June, etc)
// Get Year and Months from that list withour repeating the names
//List<string> months =
//List < string > years =