By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,694 Members | 1,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,694 IT Pros & Developers. It's quick & easy.

Operator && Error

P: n/a
When running the following code:

if (typeCheck.Checked == true && typeList.SelectedItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dave Bailey <an*******@discussions.microsoft.com> wrote:
When running the following code:

if (typeCheck.Checked == true && typeList.SelectedItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?


Well, this simplest transformation of the above is:

if ((typeCheck.Checked==true) && (typeList.SelectedItem=="3"))

However, I would expect the above to compile okay, to be honest. Could
you post a short but complete program which demonstrates the problem?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

P: n/a
Hi Dave,
I assumed that typeCheck is a checkbox & typeList is a DropDownList/ComboBox
or Listbox
If so I got a warning saying that "Possible unintended reference
comparison; to get a value comparison, cast the left hand side to type
'string'" refering to the comparision between a object ( SelectedItem ) and
a string.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
When running the following code:

if (typeCheck.Checked == true && typeList.SelectedItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave

Nov 16 '05 #3

P: n/a
Try
if ((typeCheck.Checked == true) && (typeList.SelectedItem == "3"))
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}
if it is what you wanted

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
When running the following code:

if (typeCheck.Checked == true && typeList.SelectedItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.