HomeCloud ComputingC# 14 introduces extension members

C# 14 introduces extension members



C# 14, a deliberate replace to Microsoft’s cross-platform, normal function programming language, provides an extension member syntax to construct on the acquainted characteristic of extension strategies.

Extension members enable builders to “add” strategies to current sorts with out having to create a brand new derived sort, recompile, or in any other case modify the unique sort. The newest C# 14 preview, launched with .NET 10 Preview 3, provides static extension strategies and occasion and static extension properties, based on Kathleen Pollard, principal program supervisor for .NET at Microsoft, in a Could 8 weblog submit.

Extension members additionally introduce another syntax for extension strategies. The brand new syntax is elective, and builders don’t want to vary their current extension strategies. Whatever the type, extension members add performance to sorts. That is notably helpful if builders don’t have entry to the kind’s supply code or if the kind is an interface, Pollard stated. If builders don’t like utilizing !listing.Any(), they’ll create their very own extension methodology IsEmpty(). Beginning within the newest preview, builders could make {that a} property and use it identical to some other property of the kind. Utilizing the brand new syntax, builders can also add extensions that work like static properties and strategies on the underlying sort.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments