日期:2014-05-17 浏览次数:20543 次
DateTime dtFirst=new DateTime(DateTime.Now.Year,DateTime.Now.Month,1);
for(DateTime dt=dtFirst;dt<=dtFirst.AddMonths(1).AddDays(-1);dt=dt.AddDays(1))
{
if(dt.DayOfWeek==DayOfWeek.Wednesday)
Console.WriteLine(dt.ToString());
}
DateTime firstDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
int weekDay = (int)firstDay.DayOfWeek;
if (weekDay <= 3)
{
weekDay = 3 - weekDay;
}
else
{
weekDay = 7 - (weekDay - 3);
}
int monthDay = (firstDay.AddMonths(1) - firstDay).Days;
List<DateTime> list = new List<DateTime>();
for (int i = weekDay; i <= monthDay; i += 7)
{
list.Add(firstDay.AddDays(i));
}