C# Conditionals

Basic Structure of if, else if, else

Here is the general structure of an if statement in C#

using System;

class Program {
    static void Main() {
        if (condition) {
            // code block
        }
        else if (otherCondition) {
            // code block
        }
        else {
            // code block
        }
    }
}

if Statement

Loading...
Output:

else if

Loading...
Output:

else Statement

Loading...
Output:

Nested if Statements

Loading...
Output:

switch Statement

Loading...
Output:

Pattern Matching (Preview)

Loading...
Output:

We'll explore full pattern matching later.

Practice Prompt

What will this print?

Loading...
Output:

Need Help?

Ask the AI if you need help understanding or want to dive deeper in any topic