Paul Krill
Editor at Large

C# 14 touted for extension properties declaration

news
Nov 18, 20253 mins

Productivity and performance enhancements also detailed in latest release of the .NET programming language.

A large collection of tool sockets and extensions for socket wrench
Credit: dreamnikon / Shutterstock

Although the C# 14 language was formally launched along with the .NET 10  framework a week ago, Microsoft has put the language update in view again. C# 14 features extension members, a new syntax for declaring extension properties and extension methods. Overall, C# 14โ€™s enhancements improve developer productivity and performance, the company said.

In a November 17 blog post, Microsoft introduced introduced C# 14, the latest update to the companyโ€™s popular object-oriented language for .NET, and described extension members as the headline feature. Extension methods allow developers not only to declare extension properties and extension methods, but also to declare extension members that extend the type, rather than an instance of the type. These new extension members can appear as static members of the type extended. Extensions can include user-defined operators implemented as static extension methods.

Also in C# 14 is a set of capabilities designated as offering more productivity by reducing friction for everyday tasks. These capabilities eliminate boilerplate, remove common conditional blocks, simplify lambda declarations, enhance partial types for source generators, and make nameof more expressive in generic scenarios, according to Microsoft. Typing is reduced and developers get cleaner code, fewer trivial identifiers, and code that communicates intent more cleanly. These capabilities include the following:

  • The field keyword, previewed in .NET 9, maintains autoโ€‘property terseness and injects minimal logic only where needed.
  • nameof accepts an unbound generic type. This eliminates the need to choose an arbitrary type just to retrieve the generic typeโ€™s name.
  • The null-conditional member access operators, ?. and ?[], now can be used on the left-hand side of an assignment or compound assignment.
  • Large generated or sourceโ€‘generated partial types now can spread event and constructor logic across files. This enables generators or different files to contribute cleanly.

For performance, C# 14 adds implicit conversions among arrays, spans, and read-only spans. This means less ceremony has to be written and the JIT (just-in-time) compiler sees simpler call graphs. That results in fewer temporary variables, fewer bounds checks, and more aggressive inlining in the framework, Microsoft said. Also, C# 14 lets developers declare a compound assignment operator explicitly so that the compiler dispatches directly to the developerโ€™s implementation.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorldโ€™s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorldโ€™s audience of software developers and other information technology professionals. Paul has won a โ€œBest Technology News Coverageโ€ award from IDG.

More from this author