Skip to content

C# Modernization Overview

  • C# 8 — nullable reference types, switch expressions, property patterns, using declarations, indices and ranges, async streams
  • C# 9 — records, init-only setters, target-typed new, relational and logical patterns, top-level statements
  • C# 10 — file-scoped namespaces, global usings, record structs, extended property patterns, CallerArgumentExpression
  • C# 11 — raw string literals, required members, list patterns, generic attributes, UTF-8 string literals
  • C# 12 — primary constructors, collection expressions, inline arrays, alias any type, ref readonly parameters
  • C# 13 — params collections, new lock semantics, method group natural type improvements, partial properties and indexers, ref struct interface support
  • C# 14 — extension members, field keyword for field-backed properties, null-conditional assignment, first-class Span<T> / ReadOnlySpan<T> conversions

When modernizing .NET code, start with these new language features:

  • nullable reference types
  • pattern matching and switch expressions
  • records, init, and required
  • file-scoped namespaces and global usings
  • raw string literals
  • collection expressions
  • selected performance-oriented features such as spans and params collections where they provide measurable value
  • enable nullable reference types
  • replace brittle null handling with explicit intent
  • modernize branching logic with pattern matching
  • use records for value-like data models
  • use init and required where immutable initialization is the goal
  • introduce file-scoped namespaces
  • add global usings carefully
  • replace noisy string escaping with raw string literals
  • use ranges, spans, and params collections where they remove allocations or simplify hot-path code
  • measure before optimizing