Introduction
The C# programming language allows you to build applications that employ decision-making logic.
Suppose you want to display different information to the end user depending on some business rules. For example, what if you want to display a special message on a customer's bill based on their geographic region? What if you want to give a customer a discount based on the size of their order? Or what if you want to display an employee's title based on their level in the company. In each case, you would need to add decision logic.
By the end of this module, you'll be able to write code that can change the flow of your code's execution based on some criteria.
Important
This module includes coding activities that require Visual Studio Code. You'll need access to a development environment that has Visual Studio Code installed and configured for C# application development.
Learning objectives
In this module, you will:
- Write code that evaluates conditions by using the statements
if
,else
, andelse if
. - Build Boolean expressions to evaluate a condition.
- Combine Boolean expressions using logical operators.
- Nest code blocks within other code blocks.
Prerequisites
- Experience using Visual Studio Code to create and run C# console applications.
- Experience printing messages to the console using
Console.WriteLine()
. - Experience with string interpolation to combine variables into literal strings.
- Experience working with the
System.Random
class to generate random numbers.