时间操作

//将202004这样的格式转换为时间格式

DateTime date = DateTime.ParseExact(datetime, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);

//本月天数

int days = DateTime.DaysInMonth(date.Year, date.Month);
//本月第一天
DateTime beginTime = date.AddDays(1 - (date.Day));

//本月最后一天
DateTime endTime = beginTime.AddDays(days - 1);
List<NumData> dateList = new List<NumData>();
for (DateTime dt = beginTime; dt <= endTime; dt = dt.AddDays(1))
{
dateList.Add(new NumData { time=dt.Date, Score=null});
}

原文地址:https://www.cnblogs.com/ly-03-04/p/13072330.html