计算两个时间之间的日期
/// <summary> /// 计算两个时间之间的日期 /// </summary> /// <param name="startDate">开始日期</param> /// <param name="endDate">结束日期</param> /// <returns>日期集合</returns> /// <exception cref="ArgumentException">异常</exception> private static IEnumerable<DateTime> GetDateTimes(DateTime startDate, DateTime endDate) { if (endDate < startDate) { throw new ArgumentException(nameof(startDate)); } var result = new List<DateTime>(); for (var date = startDate; date <= endDate; date = date.AddDays(1)) { result.Add(date); } return result; }