473,511 Members | 14,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Operator && Error

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
3 6971
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2017
by: Zenon | last post by:
Folks, I have been trying for a week but I cannot debug the following error: Error E2285 ex5.cpp 141: Could not find a match for 'matrix<complex<double>>::operator =(complex<double>)' in...
9
1693
by: Marchello | last post by:
Hi All. I will try to explain my question on following example: Having class CInteger (wraper on 'int' values): class CInteger { public: ..... void SetValueFromPoiner(int *new_value)
2
4572
by: David Laub | last post by:
I know there is no C# exponentiation operator. But since the double class is sealed, there seems no way to add the operator override without creating a new class which uses containment (of a...
1
1790
by: sd2004 | last post by:
Could someone please help ? I am getting compiling error but do not understand why ? below is snipset of code: istream& operator>>(istream& is, test_ins& s){ is >>s.pass>>s.put>>s.type; ...
2
4438
by: linq936 | last post by:
Hi, I have this piece code, struct TriStr { MyString str1; MyString str2; MyString str3; TriStr(MyString s1, MyString s2, MyString s3){ this->str1 = s1;
6
2306
by: Angel Tsankov | last post by:
How can an overloaded operator& take the address of its argument: template<typename T> Smth operator &(T& SomeObject) { // The address of SomeObject is needed here }
39
4679
by: dancer | last post by:
Can somebody tell me why I get this message with the following code? Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.TextBox'. ...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.