Modern C#
Nullable reference types, init and required, records and record structs, primary constructors, file-scoped namespaces, global using, raw string literals, collection expressions, list patterns, interceptors and static abstract interface members.
-
Review this code from a project that has just enabled nullable reference types: it is full of `!` operators, `= default!` on properties, and helper methods like TryGetCustomer that the compiler does not understand. What is wrong, and how do you make nullable annotations actually protect you? Cover the nullable attributes, generics with T?, EF Core and deserialisation.
Advanced nullable reference types: code review of common misuse, nullable attributes, generics and framework boundaries.
Mid-Level
CodeReview
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
How do init and required work together in C#? Explain init-only setters (C# 9), required members (C# 11), what the compiler enforces, SetsRequiredMembers, how they interact with constructors, object initialisers, with expressions and System.Text.Json, and when you would choose a constructor instead.
init-only setters and required members: object initialisation contracts, constructors, with expressions and deserialisation.
Mid-Level
Theory
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
How do you use records well in production C#? Explain what the compiler generates for a record class (equality, EqualityContract, ToString, Deconstruct, copy constructor), how inheritance affects equality, why with is a shallow copy, the collection-equality trap, and where records fit or do not fit (DTOs, value objects, EF Core entities).
Practical record class usage: generated members, inheritance, with expressions, collection equality and EF Core fit.
Mid-Level
Theory
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
What is a record struct in C# 10, and how does it differ from a record class and a plain struct? Explain readonly record struct, the mutability default, generated equality versus ValueType.Equals, with expressions on structs, the default value problem, and when a record struct is the right choice.
record struct and readonly record struct: semantics, equality performance, default values and when to choose them.
Mid-Level
Theory
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
How do primary constructors on classes and structs (C# 12) differ from those on records? Explain parameter capture, why parameters are not properties, the double-storage warning CS9124, mutation of captured parameters, validation, use with dependency injection, and the pitfalls you would flag in review.
C# 12 primary constructors for classes and structs: capture semantics, warnings, DI usage and review pitfalls.
Mid-Level
CodeReview
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
What are file-scoped namespaces, global using directives and implicit usings in modern C#? Explain how each works, where to put global usings, how ImplicitUsings and the Using MSBuild item generate them, global using static and alias directives (including C# 12 alias any type), and the problems they can cause in large solutions.
File-scoped namespaces (C# 10), global usings, implicit usings and using aliases in modern projects.
Junior
Theory
Modern C#
Β· π 2 follow-ups
-
What are raw string literals in C# 11? Explain the triple-quote syntax, how indentation is removed, including quotes inside the text, interpolated raw strings with multiple dollar signs, UTF-8 raw strings, and where they help in real code such as JSON, SQL and test fixtures.
Raw string literals: syntax, indentation rules, interpolation with $$ and practical uses.
Junior
Theory
Modern C#
Β· π 2 follow-ups
-
What are collection expressions in C# 12? Explain the [a, b, ..c] syntax, which target types they support (arrays, spans, lists, interfaces, CollectionBuilder types), why they have no natural type, how the compiler chooses an efficient implementation, the spread operator, and the performance and API design implications.
Collection expressions: syntax, target typing, CollectionBuilder, spread and performance behaviour.
Mid-Level
Theory
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
How do list patterns work in C# 11? Explain matching on length and elements, the discard and slice patterns, capturing a slice with .. var rest, which types support list patterns (countable and indexable, plus slicing support), the allocation cost of slices for arrays, lists, strings and spans, and real uses such as command parsing.
List patterns: syntax, slice patterns, type requirements, slice costs and practical uses.
Mid-Level
Coding
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
What are interceptors in C#, and what should a .NET developer know about them? Explain what problem they solve, how a source generator uses InterceptsLocation to redirect a specific call site, the InterceptorsNamespaces opt-in, where .NET already uses them (Request Delegate Generator, configuration binding generator), and why you should not hand-write them.
Awareness of interceptors: purpose, mechanics, opt-in, built-in uses and limits.
Senior
Theory
Modern C#
Β· π 3 follow-ups Β· π 1 real-world
-
Write generic numeric code in C# using static abstract interface members and generic math (.NET 7+). Explain INumber<T> and the smaller interfaces, T.Zero and T.CreateChecked, IParsable<T>, how to make your own type participate (operators as static abstract members, the self-referencing constraint), checked operators, and the performance and design trade-offs.
Generic math with static abstract interface members: writing and consuming numeric generic code.
Senior
Coding
Modern C#
Β· π 3 follow-ups Β· π 1 real-world