.NET January 13, 2026
3 min read

.NET 10 and C# 14 — Extension members

Extension methods have been a part of C# for a long time, allowing us to add methods to types we do not own. However, we were limited to only methods. Now, in C# 14, we have Extension Members, which allow us to add static members, such as methods and properties, to a type via an extension. In this article, I present how to use this feature.

Extension Methods

Before going to extension members, let’s do a quick recap about Extension Methods, since extension members are built on the same idea. Extension methods allow you to add new methods to an existing type without modifying its source code. For that, we had to create a static class, and define static methods using the this modifier. For example, this is an extension method that checks if a string is capitalized:

public static class StringExtensions
{
   public static bool IsCapitalized(this string str)
	   => !string.IsNullOrEmpty(str) && char.IsUpper(str[0]);
}

The this string str, tells the compiler that IsCapitalized is an extension method for string. This means we can add a new method to the string type, without having to modify the string class. To use it, call the IsCapitalized method directly from the string:

string name = "Henrique";
bool capitalized = name.IsCapitalized();
Console.WriteLine($"Is capitalized: {capitalized}");

// Output:
Is capitalized: True

Extension Members vs Extension Methods

We can also create extension methods for our own types. This is an example of extension methods for the Order object that I created for demonstration purposes:

public static class OrderExtensionMethods
{
	public static void MarkAsProcessedExtensionMethodDemo(this Order order)
		 => order.Status = "Shipped";

	public static void PrintStatusExtensionMethodDemo(this Order order)
		=> Console.WriteLine($"Order Status: {order.Status}");
}

This works perfectly, but note that adding multiple methods requires repeating the this Order order parameter every time, and we are still unable to add properties to the Order type using this syntax.

Now with C# 14, with Extension Members, we have a new syntax using the extension keyword. For example:

public static class OrderExtensionMembers
{
	extension (Order order)
	{
		public void MarkAsProcessedExtensionMemberDemo()
			=> order.Status = "Shipped";

		public void PrintStatusExtensionMemberDemo()
			=> Console.WriteLine($"Order Status: {order.Status}");

		// Adding a property, this was not possible before
		public string UppercaseStatus => order.Status?.ToUpper() ?? "UNKNOWN";
	}
}

This is basically the same as using extension methods, but with a new syntax which allows grouping the extension methods for a specific type in one block, remove the need to repeat this Order order for each method, and it also offers the possibility to include new properties, like the UppercaseStatus computed property, which was included in this example.

The usage is identical to extension methods:

var order = new Order { Status = "Processed" };

order.PrintStatusExtensionMemberDemo();
order.MarkAsProcessedExtensionMemberDemo();
order.PrintStatusExtensionMemberDemo();

Console.WriteLine($"Uppercase Status: {order.UppercaseStatus}");

// Output:
Order Status: Processed
Order Status: Shipped
Uppercase Status: SHIPPED

Conclusion

Extension Members in C# 14 are useful for grouping methods within a single extension block. This new syntax also allows the inclusion of computed properties, making it easier to organise your code into logical blocks.

This is the link for the project in GitHub: https://github.com/henriquesd/DotNet10.CSharp14.Demo

If you like this demo, I kindly ask you to give a ⭐️ in the repository.

Thanks for reading!


References

What’s new in C# 14