/// <summary>
/// 获取时间范围某个星期几所有日期
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <param name="DayOfWeek"></param>
/// <returns></returns>
private List<DateTime> GetDays(DateTime startDate, DateTime? endDate, DayOfWeek? DayOfWeek)
{
var dateTimes = new List<DateTime>();
int day = 1;
while (startDate < endDate)
{
if (startDate.DayOfWeek == DayOfWeek)
{
day = 7;
dateTimes.Add(startDate);
}
startDate = startDate.AddDays(day);
}
return dateTimes;
}
07-23
772
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)