Search⌘ K
AI Features

Quiz Yourself: C# Basics

Check your understanding of C# case sensitivity, syntax rules, type casting, and control flow structures.

We'll cover the following...

C# Basics Quiz

1.

Consider the following code snippet regarding block scope. What is the outcome when this code is compiled and executed?

static void Main()
{
    int score = 10;
    {
        score = 20;
    }
    Console.WriteLine(score);
}
A.

The console displays 10 because the change happened inside a separate block.

B.

The console displays 20 because the inner block has access to the outer variable.

C.

A compile-time error occurs because score cannot be modified inside the inner block.

D.

A runtime exception is thrown because the variable score is disposed of when the block ends.


1 / 14