如果我有一个约会列表并且想在几周内而不是在一个循环中获得这些约会,例如。
public class appointments
{
public string Appointment { get; set; }
public DateTime Start { get; set; }
public string Location { get; set; }
}
List<appointments> appointment = new List<appointments>();
appointment.Add(new appointments() { Appointment = "meeting", Start = new DateTime(2013, 01,02), Location = "office"});
appointment.Add(new appointments() { Appointment = "lunch", Start = new DateTime(2013, 01, 07), Location = "cafe" });
appointment.Add(new appointments() { Appointment = "meeting", Start = new DateTime(2013, 01, 08), Location = "cityhall" });
appointment.Add(new appointments() { Appointment = "dentist", Start = new DateTime(2013, 01, 14), Location = "dentist" });
现在我想要一个从 say2013-01-02
到 的时间2013-01-25
段,并且 startdate 01-02 将是开始周。
所以 02 到 08 之间的项目是一周 09-16 另一个,依此类推,直到其一周内有 7 天的末尾。我如何迭代列表并将特定的几周传递给另一种方法,而不预先计算“周制动日期”,只需添加 7 天直到结束?