Build on a Programmable Card with Klutchcard (Sponsored)
What if your card could enforce budgets, pause subscriptions, and limit merchants automatically?
Klutchcard gives developers a programmable card with full API access, unlimited virtual cards, and rule-based controls so you can automate subscriptions, cap spend per merchant, and test payments safely in real workflows.
Build mini-apps on top of the card — like auto-pausing failed subscriptions or enforcing budgets in real time, using clear docs, Postman collections, and real examples.
Still spending hours setting up cloud infra for your .NET apps? (Sponsored)
Fly.io helps you deploy full-stack, stateful .NET apps in minutes: frontend, API, and database — all running close to users worldwide with predictable pricing.
C# 14 introduces the extension keyword, bringing a modern approach to extending types.
The new syntax separates the receiver (the type you're extending) from the members you're adding.
Instead of putting this on each method parameter, you declare an extension block that specifies the receiver once:
The extension block takes the receiver as a parameter.
Inside the block, you write your methods and properties just like they were actual members of the type.
The value parameter is available to all members within the block.
Both old and new syntax compile to identical code, so they work the same way.
The new syntax is optional and designed to work alongside the traditional this parameter approach.
Extension properties make your code more readable and expressive. Instead of calling methods, you can use properties that feel more natural.
For example, when working with collections, you frequently check if they're empty.
Instead of writing !items.Any() everywhere, you can create an IsEmpty property:
csharp
1publicstaticclassCollectionExtensions2{3extension<T>(IEnumerable<T> source)4{5publicbool IsEmpty =>!source.Any();67publicbool HasItems => source.Any();89publicint Count => source.Count();10}11}1213publicvoidProcessOrders(IEnumerable<Order> orders)14{15if(orders.IsEmpty)16{17 Console.WriteLine("No orders to process");18return;19}2021foreach(var order in orders)22{23// Process order24}25}
Static extensions allow you to add factory methods or utility functions to a type, rather than to an instance.
To create static extensions, use extension without naming the receiver parameter:
You can also add type constraints to ensure your extensions only work with specific types.
Here's an extension that works only with numeric types:
csharp
1publicstaticclassNumericExtensions2{3extension<T>(IEnumerable<T> source)4whereT:INumber<T>5{6publicTSum()7{8var total = T.Zero;9foreach(var item in source)10{11 total += item;12}13return total;14}1516publicTAverage()17{18var enumerable = source.ToList();1920var sum = enumerable.Sum();21var count = T.CreateChecked(enumerable.Count);2223return sum / count;24}2526publicIEnumerable<T>GreaterThan(T threshold)=>27 source.Where(x => x > threshold);28}29}
This extension works with any numeric type that implements INumber<T>:
When using the extension keyword, you can group multiple extension members that apply to the same type in a single extension block.
This reduces repetition and keeps related code together.
You can have multiple extension blocks in one static class if you need different receivers or different generic type parameters:
The choice of organizing your extensions depends on your project needs.
You might create separate static classes for each type you're extending, or you might group related extensions by functionality.
Add XML code summary on big projects to help other developers understand what your extensions do:
csharp
1extension(Product product)2{3/// <summary>4/// Gets whether the product is currently available for purchase.5/// </summary>6/// <remarks>7/// A product is available if its stock quantity is greater than zero.8/// </remarks>9publicbool IsAvailable => product.StockQuantity >0;10}
The extension keyword in C# 14 is optional. Your existing extension methods continue to work without changes.
However, when you need to add properties, static members or want cleaner syntax for grouping related extensions, the new approach provides a better developer experience.
As you work with C# 14 and .NET 10, experiment with extension properties in your projects.
You'll find opportunities to replace methods with properties, making your code more intuitive and easier to use.
If you want to learn more about .NET 10 and C# 14 features, I recommend checking this article.
Hope you find this newsletter useful. See you next time.
You can download source code for this newsletter for free
The .NET Senior Playbook — 800+ real-world interview questions with expert answers across 50 chapters. You try to answer each question first, then reveal the full solution — and a test after every chapter proves it actually stuck. Finish, and you earn a verifiable certificate for your LinkedIn.