Modern C# features: primary constructors, collection expressions, pattern matching

C# Language Interview Q&A November 13, 2026 csharp

Features used day to day: primary constructors and collection expressions (C# 12), required + init properties, switch expressions with patterns, property patterns, plus records, file-scoped namespaces, global usings and raw string literals.

csharp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// ======================================================================
// Q: Which modern C# features do you use?
//
// Features used day to day: primary constructors and collection expressions (C#
// 12), required + init properties, switch expressions with patterns, property
// patterns, plus records, file-scoped namespaces, global usings and raw string
// literals.
// ======================================================================

public class OrderService(IOrderRepository repo, ILogger<OrderService> log) { }  // primary ctor (C# 12)
int[] ids = [1, 2, 3];                                       // collection expressions (C# 12)
public required string Sku { get; init; }                    // required + init
var label = status switch                                    // switch expression + patterns
{
    OrderStatus.Draft or OrderStatus.Placed => "Open",
    OrderStatus.Shipped                     => "Done",
    _                                       => "Other"
};
if (order is { Status: OrderStatus.Placed, TotalNet: > 1000 }) { /* property pattern */ }
// + records, file-scoped namespaces, global usings, raw string literals ("""...""")