日期:2014-05-17  浏览次数:20552 次

如何绑定当月所有周三的日期?
如何绑定当月所有周三的日期?
绑定日期

------解决方案--------------------
    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));
            }

------解决方案--------------------
 DateTime dtTemp = new DateTime();
            DateTime dt = DateTime.Now;