I'm attempting to write my first C# script. The script is for opening hours... My if ((weekDay == sunday) && time > openingTime && closingTime < time)
line is spitting errors due to:
CS0019 C# Operator '<' cannot be applied to operands of type 'string' and 'int'
After looking at related answers on SO, I still haven't been able to get my code working. I've tried converting the string
into an int
, this didn't work (unless I did something stupid)
var weekDay = DateTime.Today.DayOfWeek;
var isOpen = "We are open!";
var isClosed = "We are closed";
var sunday = DayOfWeek.Sunday;
var time = DateTime.Now.ToString("hh:mm");
var openingTime = 08;
var closingTime = 16;
if ((weekDay == sunday) && time > openingTime && time < closingTime)
{
Console.WriteLine(isClosed);
}