I wrote some if-else statements like this:
if (workedDays > 0 && workedDays <= 180)
{
x= 14;
}
if (workedDays > 180 && workedDays <= 540)
{
x= 28;
}
if (workedDays > 540 && workedDays <= 1068)
{
x= 42;
}
else
{
x= 56;
}
I was trying to rewrite it as switch statement like this:
switch (workedDays)
{
case (workedDays > 0 && workedDays <= 180):
x=14;
break;
default:
break;
}
However, I am getting the error Cannot implicitly convert type 'bool' to 'int'
.
How can I fix it?