DateTime someDay = new DateTime(2009, 6, 10); //此处换成你实际的日期 int wd = (int)someDay.DayOfWeek; for (int i = 1 - wd; i < 8 - wd; i++) { DateTime currentDay = someDay.AddDays(i); Console.Write(currentDay.ToShortDateString()); Console.Write("----"); Console.WriteLine(currentDay.DayOfWeek); }
注明:上面的算法,是以星期一为每周的开始,星期天为每周的结束的(符合中国人的思维方式)
转载于:https://blog.51cto.com/lightweight/473852