给定一个日期,如何找到(类的DateTime
)的第三个周五在该日期的月份?
Given a date (of type DateTime
), how do I find the 3rd Friday in the month of that date?
我没有测试过这一点,但由于第三个星期五不可能在本月15日之前发生的,创建一个新的日期时间,然后就开始递增,直到你到了周五。
I haven't tested this, but since the third Friday can't possibly occur before the 15th of the month, create a new DateTime, then just increment until you get to a Friday.
DateTime thirdFriday= new DateTime(yourDate.Year, yourDate.Month, 15);
while (thirdFriday.DayOfWeek != DayOfWeek.Friday)
{
thirdFriday = thirdFriday.AddDays(1);
}
上一篇:当给定的部分限定的类型名称如何Type.GetType工作的?名称、类型、部分、工作
下一篇:调用在C#中的WebBrowser控件的Javascript函数控件、函数、WebBrowser、Javascript