Skip to content

C# 14

It is especially relevant when adopting .NET 10 and modern APIs that rely on spans or expressive extension patterns.

Modernization Overview

Extension members expand the extension model beyond classic extension methods.

public static class StringExtensions
{
extension(string text)
{
public bool IsBlank => string.IsNullOrWhiteSpace(text);
}
}

This makes extension-based APIs more expressive by supporting additional member shapes such as properties.

The field keyword makes it possible to add logic to an auto-property without declaring a separate backing field.

public string Name
{
get;
set => field = value ?? throw new ArgumentNullException(nameof(value));
}

Legacy style:

private string _name = "";
public string Name
{
get => _name;
set => _name = value ?? throw new ArgumentNullException(nameof(value));
}

Null-conditional assignment allows conditional assignment through a null-conditional receiver.

person?.Manager = newManager;
orders?[index] = replacement;

This removes some of the small guard if statements that used to be required.

C# 14 improves built-in support for Span<T> and ReadOnlySpan<T> so these APIs can feel more natural in everyday code.

ReadOnlySpan<char> text = "hello";
ReadOnlySpan<int> values = [1, 2, 3];

This is especially relevant in performance-oriented code, but it can also make span-based APIs easier to adopt more broadly.