San Diego Website design home Contact Us Client Login


Saturday, May 17, 2008

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

I ran into this error when I was creating some validation logic with an 'if' statement.  It went something like this:

if (txtfield1.Text = "" || (txtfield2.Text = "" || txtfield3.Text = ""))

{

// display error message

}

You need to use double equal signs in this case.

it should be:

if (txtfield1.Text == "" || (txtfield2.Text == "" || txtfield3.Text == ""))

{

// display error message

}

 

Please support this blog by clicking on the sponsors to the right.

 

Good luck

Comments

Name
URL
Email
Email address is not published
Remember Me
Comments

CAPTCHA
Write the characters in the image above

San Diego Website Design
San Diego Flash Design
Testimonials
Contact Us
Support
Privacy Policy
Site Map