Hi
I am getting error - Operator == canot be applied to operands of type object and boolean
C#
if (row["status"] == true)
{
Status = "Active";
}Thanks
Hi
I am getting error - Operator == canot be applied to operands of type object and boolean
if (row["status"] == true)
{
Status = "Active";
}Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gowtham CpRank #1,552 · 1K reputationPosted Aug 19, 2024, 8:45 AM EDT
Hi,
The error happens because row["status"] is an object. You need to cast it to bool like this:
if ((bool)row["status"]) { Status = "Active"; }Or use:
if (Convert.ToBoolean(row["status"])) { Status = "Active"; }Hope this helps!