首先會利用到日期迴圈 http://todomato.blogspot.tw/2016/01/c-foreach-datetime.html
然後使用 DayOfWeek 來過濾想要的週期,(如週三)即可
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<DateTime> list = new List<DateTime>(); | |
foreach (DateTime day in DateHelper.EachDay(StartDate, EndDate)) | |
{ | |
list.Add(day); | |
} | |
list = list.Where(c => 自訂容器.Contains(c.DayOfWeek.ToString())).Tolist(); |