What’s New in .NET 9? A Developer’s Preview
Every November, a major new release of .NET introduces a mix of impactful and exciting changes for developers. Upgrading to the latest version can be challenging, especially in large-scale projects, making it crucial to understand the improvements it brings.
Last November, we welcomed .NET 9, an odd-numbered release with 18 months of support. As the successor to .NET 8, .NET 9 places a strong emphasis on cloud-native applications and performance improvements. But how will this new version truly impact a developer’s day-to-day work? Let’s find out!
As a .NET developer working with C# daily, I’m always most interested in the concrete features each new .NET release introduces — especially those I can start using right away. I’ve highlighted some of the most exciting ones that can enhance everyday development, helping you refine existing code or shape new implementations more effectively.
Feature Switches
The Feature Switches is one of those features that makes you wonder, how did we not have this before? As the name suggests, it allows you to enable or disable features effortlessly. By adding a simple flag to your feature’s class, you can control whether it gets included in the runtime or completely ignored — making feature management more flexible and efficient.
Feature switches help maintain backward compatibility while introducing new features. You can deploy a new feature in your application without fully enabling it. This allows you to keep the old functionality intact, ensuring that existing users won’t be impacted until you’re ready to turn on the new feature.
Also, this new feature enables you to implement A/B testing, where you can expose different versions of a feature to different user groups. This allows you to gather data on which version performs better or is more favored by users, without requiring a full deployment cycle.
Personally, I look forward to the fact that you can test how the introduction of a new feature affects performance in various environments. You can enable or disable features in real-time to measure the impact on application performance.
Since code speaks better than words, let’s see a simple example.
LINQ CountBy and AggregateBy
A pretty exciting improvement of the LINQ library came with the new .NET 9 version. We have new methods called CountBy and AggregateBy which simplify the process of counting and aggregating without the need to group the elements. There’s no need for creating intermediate groupings anymore or chaining LINQ operations. This not only makes your code cleaner but also boosts execution speed. We all know that performance is one of the main reasons developers sometimes hesitate to use LINQ, but with these new methods, we can now enjoy the best of both worlds — efficiency and readability.
params in C# 13: Beyond Arrays
Since C# 13 ships with the .NET 9 SDK, we are looking at one of the most exciting changes that C# 13 brought to us — params limitation to arrays is gone!
Since its introduction in C# 1.0, the params keyword has allowed developers to define methods that accept a variable number of arguments, passed as an array. This simplified method calls when the number of arguments was unknown at compile time.
Until C# 12, however, params was limited to arrays. C# 13 removes this restriction, enabling params to accept any collection type compatible with collection expressions, such as Span, IReadOnlyList, and IEnumerable. This allows developers to pass data in various forms, including lists, arrays, and even LINQ expressions. params parameters now accept any collection implementing IEnumerable, allowing smoother integration with the .NET ecosystem.
The flexibility that this brought for developers is amazing!
Thanks for joining me in exploring some of, in my opinion, the most exciting updates that this .NET version has brought to us from a developer’s perspective!