获取特定日期在一个月

问题描述:

可能重复:结果
  如何找到第三个星期五在一个月C#?

有这么一个特定的事件只会发生在一个条件的第一个第三 *的周三的*每月。我试图做到这一点像下面,

There's a condition that a specific event will occur only on first and third *Wednesday* of every month. I am trying to achieve this like below,

DateTime nextMeeting = DateTime.Today.AddDays(14);
int daysUntilWed = ((int)DayOfWeek.Wednesday - (int)nextMeeting.DayOfWeek + 7) % 7;
DateTime nextWednesday = nextMeeting.AddDays(daysUntilWed);

但我没有得到期望的结果。我肯定,我错过了一个逻辑或有ASP.NET中的任何方法,通过它我能做到这一点?
详细资料:我想通过点击一个按钮,将设置标签,以显示下周三(以先到为准)

But I am not getting the desired result. I am sure, I am missing out on a logic or is there any method in ASP.NET through which I can do that? More Detail: I am trying to display the next Wednesday (whichever is first) by clicking on a button which will set the label.

试试这个:

var FirstDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

//first wednesday
while (FirstDat.DayOfWeek != DayOfWeek.Wednesday)
       FirstDay = FirstDate.AddDays(1);

//3rd wednesday
var ThirdWed = FirstDay.AddDays(14);