if (x == true), if ((bool)sRow.Cells[1].Value) if (Convert.ToBoolean(sRow.Cells[1].Value)) .
:
if (true.Equals(sRow.Cells[1].Value))
Worked = "X";
else if (true.Equals(sRow.Cells[2].Value))
Vacation = "X";
else if (true.Equals(sRow.Cells[3].Value))
Sick = "X";
else if (true.Equals(sRow.Cells[4].Value))
Holiday = "X";
: .
, , , .
.
However, casting / conversion is not performed for DBNull, while this approach works:
object x = DBNull.Value;
if (true.Equals(x));
if (Convert.ToBoolean(x));
if ((bool)x);
source
share