0
0
C Sharp (C#)programming~20 mins

Naming conventions in C# - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
C# Naming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of variable names with different casing

What is the output of this C# code snippet?

C Sharp (C#)
using System;
class Program {
    static void Main() {
        int myVariable = 5;
        int MyVariable = 10;
        Console.WriteLine(myVariable + ", " + MyVariable);
    }
}
A10, 5
BRuntime error
CCompilation error due to duplicate variable names
D5, 10
Attempts:
2 left
💡 Hint

Remember that C# is case-sensitive when it comes to variable names.

🧠 Conceptual
intermediate
1:30remaining
Correct naming convention for constants

Which of the following is the correct naming convention for a constant in C#?

Aconst int MaxSize = 100;
Bint MAX_SIZE = 100;
Cconst int max_size = 100;
Dint maxSize = 100;
Attempts:
2 left
💡 Hint

Constants in C# are usually declared with const keyword and use PascalCase.

🔧 Debug
advanced
2:00remaining
Identify the naming convention violation

Which option violates the standard C# naming conventions for methods?

Apublic void CalculateTotal123() {}
Bpublic void calculateTotal() {}
Cpublic void Calculate_Total() {}
Dpublic void CalculateTotal() {}
Attempts:
2 left
💡 Hint

Methods in C# should use PascalCase without underscores.

📝 Syntax
advanced
1:30remaining
Which variable name causes a syntax error?

Which of the following variable names will cause a syntax error in C#?

Aint totalValue;
Bint _count;
Cint 2ndValue;
Dint value_2;
Attempts:
2 left
💡 Hint

Variable names cannot start with a digit in C#.

🚀 Application
expert
2:30remaining
Determine the number of items in a dictionary with naming conventions

Given the following C# code, how many items will the dictionary contain after execution?

C Sharp (C#)
using System.Collections.Generic;
var dict = new Dictionary<string, int>();
dict["FirstKey"] = 1;
dict["firstkey"] = 2;
dict["First_Key"] = 3;
dict["FirstKey"] = 4;
A3
B4
C1
D2
Attempts:
2 left
💡 Hint

Dictionary keys in C# are case-sensitive and exact string matches.