Add decision logic to your code in C#

Beginner
Developer
Higher Education Educator
K-12 Educator
Student
.NET

Learn to branch your code's execution path by evaluating Boolean expressions.

Learning objectives

In this module, you will:

  • Write code that evaluates conditions using if, else, and else if statements.

  • Build Boolean expressions to evaluate a condition.

  • Combine Boolean expressions using logical operators.

  • Nest code blocks within other code blocks.

Prerequisites

  • Experience declaring, initializing, and using variables with the int and bool data types.

  • Experience printing messages to output by using Console.WriteLine() and string interpolation.

  • Experience working with the Random class to generate random numbers.