using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace weekDemo{ class Program { static void Main(string[] args) { DayOfWeek[] dw = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek .Sunday}; var query = GetWeekDays(DateTime.Now, DateTime.Now.AddMonths(1), dw); foreach (var item in query.ToList()) { Console.WriteLine(item.ToShortDateString() + "--星期:" + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(item.DayOfWeek)); } } public static IEnumerableGetWeekDays(DateTime begin, DateTime end,DayOfWeek[] dws) { return Enumerable.Range(0, (end - begin).Days).Where(c => dws.Contains(begin.AddDays(c).DayOfWeek)).Select(c => begin.AddDays(c)); } }}