C# 14 Extension Members on .NET 10: Adding Properties and Operators to Existing Types
For years, C# extension methods let you attach helper methods to types you did not own—such as IEnumerable<T> or System.Drawing.Point—using a this parameter on a static method. That syntax had one obvious limit: you could only add instance methods, never extension properties, static members, or operators. C# 14 removes that restriction with extension members (extension blocks), giving existing types cleaner, more natural APIs when targeting .NET 10.
Editorial illustration: extension(...) blocks support instance properties, static properties, and operators alongside methods.
Summary
- C# 14 (on .NET 10 SDK / Visual Studio 2026) introduces
extension(...)blocks inside top-level, non-genericstaticclasses, allowing you to declare extension properties, static extension members, and extension operators in addition to instance methods. - Distinguish versions clearly: C# 14 adds extension methods, properties, static members, and operators (
.NET 10+), whereas extension indexers (this[int index]) are a C# 15 feature (.NET 11 SDK), per Microsoft Learn’s extension members tutorial. - Traditional
thisextension methods remain completely valid and binary/source-compatible—you do not need to rewrite existing codebases overnight. - Use
extension(ref MyStruct value)when an extension method needs to mutate a value type in place.
Prerequisites: Language, SDK, and IDE
Before writing an extension block, verify your project environment:
- Language & Runtime: Extension members were introduced in C# 14, which is supported on .NET 10 and newer (
<TargetFramework>net10.0</TargetFramework>), as documented in Microsoft Learn’s What’s new in C# 14 and Extension member declarations. - C# 15 note: If you see tutorials mentioning extension indexers (
public Point this[int index]), Microsoft Learn’s tutorial notes those require C# 15 and the .NET 11 SDK. - IDE: You can edit, build, and debug C# 14 extension members in Visual Studio 2026 or in VS Code with the C# Dev Kit and the .NET 10 SDK.
How extension(...) blocks work
Instead of repeating this Type parameter on every static method, C# 14 lets you group extensions inside an extension block inside a top-level, non-generic static class:
- Instance extension block (names a receiver parameter, e.g.,
extension<TSource>(IEnumerable<TSource> source)): Members inside can accesssourceand are called on instances (sequence.IsEmpty). - Type-level (static) extension block (specifies only the type, e.g.,
extension(Point)): Members inside extend the type itself (Point.OriginorPoint + Point).
Example 1: Adding a static property and operators to System.Drawing.Point
Adapted directly from Microsoft Learn’s extension members tutorial, here is how you can give System.Drawing.Point a readable Point.Origin static property and + / - arithmetic operators:
using System.Drawing;
namespace GeometryExtensions;
public static class PointExtensions
{
extension(Point)
{
public static Point Origin => Point.Empty;
public static Point operator +(Point left, Point right)
=> new(left.X + right.X, left.Y + right.Y);
public static Point operator -(Point left, Point right)
=> new(left.X - right.X, left.Y - right.Y);
}
extension(ref Point point)
{
public void Translate(int dx, int dy)
{
point.X += dx;
point.Y += dy;
}
}
}
At the call site, your code reads as if those members were built into Point from day one:
Point start = Point.Origin;
Point moved = start + new Point(10, 5);
moved.Translate(2, -1);
Notice the ref modifier on extension(ref Point point). Because Point is a struct (value type), omitting ref would mutate only a temporary copy of the struct, leaving moved unchanged.
Example 2: Adding an instance extension property to IEnumerable<T>
In Microsoft Learn’s What’s new in C# 14, extension properties eliminate awkward helper method parentheses when a property fits better:
public static class SequenceExtensions
{
extension<TSource>(IEnumerable<TSource> source)
{
public bool IsEmpty => !source.Any();
}
}
Calling items.IsEmpty reads naturally alongside string.IsNullOrEmpty or collection Count checks.
When to use extension blocks vs. traditional this methods
You do not need to migrate every existing this extension method. Per Microsoft Learn, traditional extension methods and C# 14 extension members are source- and binary-compatible.
- Use
extension(...)blocks when you want properties (IsEmpty), static properties (Point.Origin), or operators (+,-) on a type you do not own, or when you want to group several related extensions for one receiver type without repeatingthissignatures. - Keep traditional
thismethods when you have a single, stable helper method in a codebase that also targets.NET 8or.NET 9(which do not support C# 14).
If you are already adopting other C# 14 features in the same .NET 10 project, pair this with our walkthrough on the C# 14 field keyword and null-conditional assignment and using CancellationToken properly in async C# methods.
Common mistakes
- Forgetting
refon mutating struct extensions. Modifying properties of astructinsideextension(Point p)mutates a local copy; useextension(ref Point p)when mutation is intended. - Putting an
extensionblock inside a generic or nested static class. C# 14 requiresextensionblocks to live inside top-level, non-genericstaticclasses (put type parameters on theextension<T>(...)block itself). - Assuming extension indexers work in C# 14. Extension indexers (
this[int index]) were added in C# 15 (.NET 11), not C# 14. - Overloading operators in ways that surprise readers. Just because you can attach
+to a third-party type does not mean every team member will expect it—keep operator semantics obvious and well-scoped.
Why this matters
Before C# 14, library authors and application teams had to choose between awkward static utility classes (PointHelper.Add(p1, p2)) or wrapper structs just to get readable properties and operators on types they did not own. Extension members let you express domain helpers directly on the target type without sacrificing safety or allocation overhead.
My Take
Extension properties and static operators are the real winners in C# 14—they make domain code noticeably cleaner without forcing wrapper types. Keep traditional this methods where they already work, and reach for extension(...) blocks when adding properties, static constants, or arithmetic operators to existing types on .NET 10.
Conclusion
Verify your project targets net10.0 (C# 14), group related extensions into extension(...) blocks inside top-level static classes, use ref receivers for mutating struct methods, and keep traditional this methods where multi-target compatibility with older .NET versions is still required.