I'm converting a lot of code from VB.net to c# and here is another issue I think cropped up during the conversion.
if (sRow.Cells[1].Value == true)
Worked = "X";
else if (sRow.Cells[2].Value == true)
Vacation = "X";
else if (sRow.Cells[3].Value == true)
Sick = "X";
else if (sRow.Cells[4].Value == true)
Holiday = "X";
on each of the if / else / else if lines it gives me this error. I'm sure I am missing something that will force me to do a head bonk...
Error 7 Operator '==' cannot be applied to operands of type 'object' and 'bool'
Are you sure that these values are of type bool
?
If so, just explicitly cast:
if ((bool)sRow.Cells[1].Value)
{
Worked = "X";
}
else if ((bool)sRow.Cells[2].Value)
{
Vacation = "X";
}
else if (sRow.Cells[3].Value)
{
Sick = "X";
}
else if ((bool)sRow.Cells[4].Value)
{
Holiday = "X";
}
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