public static DateTime OrdinalDate(
OrdinalWeekday occurrence,
DayOfWeek dayOfWeek,
int year,
int month,
int day
)If the value of day is greater than the last occurrence of dayOfWeek, the last occurrence is returned.
The following table shows the output of the OrdinalDate method:
| occurrence | dayOfWeek | year | month | day | Result |
|---|---|---|---|---|---|
| First | Monday | 2014 | 10 | 1 | 2014-10-06 |
| First | Tuesday | 2014 | 11 | 1 | 2014-11-04 |
| First | Tuesday | 2005 | 11 | 2 | 2005-11-08 |
| Fourth | Tuesday | 2005 | 11 | 30 | 2005-11-29 |
| Exact | Tuesday | 2004 | 11 | 3 | 2006-11-03 |
var electionDay =
DateTimeExtensions.OrdinalDate(OrdinalWeekday.Second, DayOfWeek.Tuesday, 2014, 11, 1);
// Result: 2014-11-04