If I have a list of DateTimes or an object composed of Date Parts say:
public class CustomDate
{
public string Month;
public string Day;
public DateTime Date;
}
var cusDate = List<CustomDate>();
is it possible to take it and group the days by month to get:
June 2, 9, 12, 20 May 9, 15, 20, 25 etc ...
How do I select the date fields out of the following:
var r = dt.OrderBy(a => a.Date).GroupBy(b => b.Month).Select(a => new { a.Key});
Edit:
Final Solution to get proper formatting:
var il = String.Empty;
var groupped = dt.OrderBy(x => x.Date).GroupBy(x => x.Month);
foreach (var item in groupped)
{
il += String.Format("{0}", item.Key) + " ";
foreach (var cd in item)
{
il += String.Format("{0}", cd.Day) + ", ";
}
il = il.Trim().TrimEnd(',') + " | ";
}