MacMusic  |  PcMusic  |  440 Software  |  440 Forums  |  440TV  |  Zicos
extension
Search

C# 14 introduces extension members

Monday May 12, 2025. 09:47 PM , from InfoWorld
C# 14, a planned update to Microsoft’s cross-platform, general purpose programming language, adds an extension member syntax to build on the familiar feature of extension methods.

Extension members allow developers to “add” methods to existing types without having to create a new derived type, recompile, or otherwise modify the original type. The latest C# 14 preview, released with.NET 10 Preview 3, adds static extension methods and instance and static extension properties, according to Kathleen Pollard, principal program manager for.NET at Microsoft, in a May 8 blog post.

Extension members also introduce an alternative syntax for extension methods. The new syntax is optional, and developers do not need to change their existing extension methods. Regardless of the style, extension members add functionality to types. This is particularly useful if developers do not have access to the type’s source code or if the type is an interface, Pollard said. If developers do not like using!list.Any(), they can create their own extension method IsEmpty(). Starting in the latest preview, developers can make that a property and use it just like any other property of the type. Using the new syntax, developers also can add extensions that work like static properties and methods on the underlying type.

Creating extension members has been a long journey and many designs have been explored, Pollard said. Some needed the receiver repeated on every member; some impacted disambiguation; some placed restrictions on how developers organized extension members; some created a breaking change if updated to the new syntax; some had complicated implementations; and some just did not feel like C#, she said. The new extension member syntax preserves the enormous body of existing this-parameter extension methods while introducing new kinds of extension members, she added. It offers an alternative syntax for extension methods that is consistent with the new kinds of members and fully interchangeable with the this-parameter syntax. A general release of C# 14 is expected with.NET 10 in November 2025.
https://www.infoworld.com/article/3983346/c-sharp-14-introduces-extension-members.html

Related News

News copyright owned by their original publishers | Copyright © 2004 - 2025 Zicos / 440Network
Current Date
May, Tue 13 - 11:54 CEST