Conditional Logic in C#
Conditional Logic in C#: If, Multiple Conditions, Switch, Switch Expressions and the Conditional Operator.
Updated
- If (Novice): Run code only when a condition is true, with if, if-else and else if, and write conditions with C#'s comparison operators.
- Multiple Conditions (Apprentice): Combine conditions with && (and), || (or) and ! (not), and group them with parentheses so they mean what you intend.
- Switch (Apprentice): Pick one of many blocks of code by the value of a single variable with C#'s switch statement, including shared cases and a default.
- Switch Expressions and the Conditional Operator (Apprentice): Choose a value, rather than run a block, with C#'s conditional operator for two choices and a switch expression for many.