Professional
1l6xhbR
1l6xhbR
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Operator Meaning Example Outcome if age is 42<br />
< Less than age < 21 false<br />
16 true<br />
>= Greater than or equal to age >= 30 true<br />
Understanding conditional logical operators<br />
C# also provides two other binary Boolean operators: the logical AND operator, which is represented<br />
by the && symbol, and the logical OR operator, which is represented by the || symbol. Collectively,<br />
these are known as the conditional logical operators. Their purpose is to combine two Boolean<br />
expressions or values into a single Boolean result. These operators are similar to the equality and<br />
relational operators in that the value of the expressions in which they appear is either true or false,<br />
but they differ in that the values on which they operate must also be either true or false.<br />
The outcome of the && operator is true if and only if both of the Boolean expressions it’s evaluating<br />
are true. For example, the following statement assigns the value true to validPercentage if and only<br />
if the value of percent is greater than or equal to 0 and the value of percent is less than or equal to<br />
100:<br />
bool validPercentage;<br />
validPercentage = (percent >= 0) && (percent = 0 && = 0 && percent = 0) && (percent = and