C#实现根据传入时间段,找出时间段内日期
【1】获取固定日期范围内的所有日期,以数组形式返回
////// 获取固定日期范围内的所有日期,以数组形式返回 /// /// /// private DateTime[] GetAllDays(DateTime startTime ,DateTime endTime) { List listDay = new List (); DateTime dtDay = new DateTime(); //循环比较,取出日期; for (dtDay = startTime; dtDay.CompareTo(endTime) <= 0;dtDay = dtDay.AddDays(1)) { listDay.Add(dtDay); } return listDay.ToArray(); }