C# Conditional Branching

Difficulty: Beginner
Duration: 1 minute and 32 seconds
Students: 337
Rating: 4.7/5

 

The ability for software to perform tasks or functions based on the state of variables or data is intrinsic to programming. In plain language, that means responding appropriately to input from the user or some data feed. C# Conditional Branching primarily focuses on If and Switch statements, the main mechanisms for executing or branching to different code depending on whether a condition is true or false. A simple example is allowing users to log in if their username and password match those stored in the software.

Learning Objectives

  • Learn and understand If-statement syntax and how to use it in different scenarios
  • Learn and understand the Switch statement and how to use it 
  • Learn about evaluating multiple Boolean conditions
  • See how the dotnet new command has changed with the release of .NET 6.0 and C# 10

Intended Audience

This lesson is intended for students that are relatively new to programming but not absolute beginners and want to know how to make their software responsive and adaptive. Students should know the basics of a C# programs structure and have experience running a program within their development environment. While for-loops and object-oriented concepts will be mentioned in the lesson, in-depth knowledge of these topics isn't essential.

Prerequisites

Demo Source Code

https://github.com/cloudacademy/csharp-conditional-branch