I want to do something if the day, and time of the day equal true in a if statement. I have the day part down, just can't figure out the time part out. Let say I wan the time to be 9AM.
Here is what I have so far
var dt_check_monday = DateTime.Now.DayOfWeek;
if (dt_check_monday == DayOfWeek.Monday && time_now = DateTime.Now.Hour==9)
{
//do something
}
I can't use this I get an error:
Operator '&&' cannot be applied to operands of type 'bool' and 'System.TimeSpan'
Thanks for any help in advance.
I think time_now
is having TimeSpan
datatype. So you can try this
if (dt_check_monday == DayOfWeek.Monday && time_now.Hours == 9)
{
//do something
}