C# Quiz
Test your C# knowledge. — 8 questions
About the C# Quiz
Test your C# knowledge. This quiz has 8 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.
The questions follow the material in the C# Fundamentals guide and the C# cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.
Questions in this quiz
Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.
1. What is the correct way to declare a nullable string in C#?
Show answer
Answer: B. string? s = null;
C# uses the ? suffix for nullable reference types: string? s = null;
2. Which LINQ method filters elements based on a condition?
Show answer
Answer: C. Where
Where(predicate) filters a sequence, returning only elements that satisfy the predicate.
3. What does the ?? operator do in C#?
Show answer
Answer: B. Returns the left value if not null, otherwise the right
?? is null-coalescing: a ?? b returns a if a is not null, otherwise returns b.
4. What should an async method return instead of void?
Show answer
Answer: C. Task
async methods must return Task or Task<T>. async void cannot be awaited and silently swallows exceptions.
5. Which symbol is used for inheritance in C#?
Show answer
Answer: D. :
C# uses the colon : for both inheritance (class Dog : Animal) and interface implementation.
6. What can foreach iterate over?
Show answer
Answer: C. Any IEnumerable<T>
foreach works on any type implementing IEnumerable<T>: arrays, lists, and custom collections.
7. What is a record type in C#?
Show answer
Answer: B. An immutable reference type with value-based equality
Records are reference types with positional properties and structural equality, ideal for immutable data models.
8. Which access modifier limits visibility to the declaring class only?
Show answer
Answer: C. private
private members are only accessible within the class that declares them.
How to use this quiz
- Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
- Note the questions you missed and revisit the matching section of the guide or cheatsheet.
- Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.