Conditional Logic in C#

Conditional Logic in C#: If, Multiple Conditions, Switch, Switch Expressions and the Conditional Operator.

Updated

  1. 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.
  2. Multiple Conditions (Apprentice): Combine conditions with && (and), || (or) and ! (not), and group them with parentheses so they mean what you intend.
  3. 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.
  4. 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.