C# Quiz

Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.

1. What does the C# compiler turn your source code into?

2. How do you run a single file called app.cs with .NET 10?

3. What does Console.WriteLine(7 / 2); print?

4. Which type should you use for money?

5. What does Math.Round(2.5) return by default?

6. Why is int.TryParse usually better than int.Parse for user input?

7. What is the value of name ?? "guest" when name is null?

8. What happens if a case in a C# switch statement has no break before the next case?

9. Which loop always runs its body at least once?

10. What does name.ToUpper(); on its own line do to name?

11. In $"{price,8:F2}", what does 8 mean?

12. What's the difference between ref and out parameters?

13. What is values[^1]?

14. Which collection should you choose to look values up by a key quickly?

15. What happens if you remove items from a List inside a foreach over that same list?

16. After var b = a; where a is an object of a class, what happens when you change b.Name?

17. What does { get; private set; } on a property mean?

18. What does the C# 14 field keyword refer to inside a property accessor?

19. Which statement about static members is true?

20. For a method to be overridden in a derived class, the base method must be marked…

21. What's a key difference between an abstract class and an interface?

22. Two records new Point(1, 2) and new Point(1, 2) are compared with ==. The result is…

23. Why does [Flags] matter on an enum like Permissions.Read | Permissions.Write?

24. With nullable reference types enabled, what does string? mean?

25. Which pattern matches an array whose first element is 1, whatever its length (at least one element)?

26. What does where T : IComparable<T> do in a generic method?

27. When does a LINQ query like numbers.Where(n => n > 5) actually run?

28. What's the right way to rethrow a caught exception while keeping its original stack trace?

29. What does a using declaration such as using var file = new StreamWriter("a.txt"); guarantee?

30. Two independent async downloads each take 1 second. How do you run them so the total is about 1 second?

How did you do?

  • 27–30: excellent — you've got a solid grasp of C#. Try the final project's challenges.
  • 20–26: good — revisit the lessons mentioned in the explanations you missed.
  • Below 20: work through the exercises and re-read the parts of the course that felt shaky, then try again.