如果我有一個約會列表,並希望在一個周而不是一個循環中獲得這些,例如。循環遍歷時間週期得到幾周
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" });
現在我想從說2013-01-02
到2013-01-25
一個TIMEPERIOD,並開始日期01-02將要開始的一週。
因此,02到08之間的項目是一個星期09-16另一個等等,直到最後一個星期內有7天。我怎麼能迭代列表,並將特定的星期傳遞給另一個方法,而不需要預先計算「星期制動日期」,直到結束時加上7天?
在某個特定的日子裏,像星期一或星期天一樣開始嗎?或者,你只是想以7天的塊來迭代嗎? – Jodrell