-
simple IF statement
bit of a slow day!
I want to check if:
textbox1 or textbox2 length == 0 AND IF checkbox1 OR checkbox2 is checked then validation has failed
how can I do this?
This doesnt work:
if (this.textbox1.Length == 0 || this.textbox2.Length == 0 && this.checkbox1.Checked || this.checkbox2.Checked)
{
//validation failed.
}
-
Re: simple IF statement
Do you know what order those logical operators are going to be evaluated in? If you want to control the order of evaluation then use parentheses, just like a mathematical equation.
Also, the TextBox class doesn't have a Length property. It would have to be either TextLength or Text.Length.
-
Re: simple IF statement
sorry yes you are right (i was just typing it in here). And managed to solve it after I posted lol
Thanks jm ;)