Making Decisions Using if Statements
By far the most common decision-making construct used in programming is the if construct. A simple if construct looks like this:
if (expression) ... statement to execute when expression is true;
The if construct uses Boolean logic, as discussed in Hour 13, “Performing Arithmetic, String Manipulation, and Date/Time Adjustments,” to evaluate an expression to either true or false. The expression may be simple (if (x == 6)) or complicated (if (x==6 && y>10)). If the expression evaluates to true, the statement or block of statements (if enclosed in braces) gets executed. If the expression evaluates to false, C# doesn't execute the statement or statement block for the if construct.
Remember that compound, also ...