Id like to Compare a date to see if it is before Saturday like so:
//Check if Saturday YET
if (MYWorkDay.DayOfWeek < DateTime.DayOfWeek.Saturday)
IGottaWork();
else
Party();
There seems to be no way to do this.
Is there a way?
Thanks in advance
Why not this?
if (MYWorkDay.DayOfWeek != DayOfWeek.Saturday
&& MYWorkDay.DayOfWeek != DayOfWeek.Sunday)
{
IGottaWork();
}
else
Party();
Or even better:
List<DayOfWeek> partyDays = new List<DayOfWeek> {
DayOfWeek.Saturday, DayOfWeek.Sunday
};
if (partyDays.Contains(MYWorkDay.DayOfWeek))
Party();
else
IGottaWork();
From MSDN:
The value of the constants in the DayOfWeek enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday).
So you can also use greater than and less than operators for your calculation.
//Check if Saturday YET
if (MYWorkDay.DayOfWeek < DayOfWeek.Saturday && MYWorkDay.DayOfWeek > DayOfWeek.Sunday)
IGottaWork();
else
Party();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With