Skip to content

C# Feature - Extension members

Extension members let you add methods, properties, and some operators to an existing type without modifying the original source type.

This feature was introduced in C# 14. The official Microsoft Learn page for C# 14 is dated November 18, 2025 and states that C# 14 ships with .NET 10 and Visual Studio 2026.

Before C# 14, extension methods used the this modifier on the first parameter of a static method. That syntax worked, but it was limited to methods. C# 14 adds extension blocks so related extension members can be grouped together and expressed more naturally.

  • Extension blocks can declare multiple extension members in one place.
  • Extension properties are now supported.
  • Static extension members can target the type itself, not only an instance.
  • Existing this-parameter extension methods still work and remain source-compatible.
public static class StringExtensions
{
extension(string text)
{
public int WordCount() =>
text.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length;
}
}

Usage:

string sentence = "C# extension members are easier to organize";
Console.WriteLine(sentence.WordCount());
  • Use extension members when you want to add focused helper behavior to types you do not own.
  • Use extension blocks when several related extension members belong together.
  • Prefer ordinary instance members when you control the original type and the behavior is core to that type.
  • Extension members never override real instance members of the target type.
  • They only participate when the defining namespace is in scope.
  • Adding too many broad extensions can make APIs harder to discover and reason about.