2.6. Conditional Logic

In many ways, conditional logic—deciding which action to take based on user input, external conditions, or other information—is the heart of programming.

All conditional logic starts with a condition: a simple expression that can be evaluated to true or false. Your code can then make a decision to execute different logic depending on the outcome of the condition. To build a condition, you can use any combination of literal values or variables along with logical operators. Table 2-7 lists the basic logical operators.

Table 2.7. Logical Operators
OperatorDescription
==Equal to.
!=Not equal to.
<Less than.
>Greater than.
<=Less than or equal to.
>=Greater than or equal to.
&&Logical and (evaluates to true only if both expressions ...

Get Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.