Conditional Logic in C#

Conditional Logic in C#: If, Where a Variable Lives: Scope and Code Blocks, 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. Where a Variable Lives: Scope and Code Blocks (Novice): A variable can be used only inside the block where it's declared, so you'll learn to declare each one where the code that needs it can see it, and how blocks, methods, classes and namespaces nest.
  3. Multiple Conditions (Apprentice): Combine conditions with && (and), || (or) and ! (not), and group them with parentheses so they mean what you intend.
  4. 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.
  5. 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.