-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
As of C# 14.0, "extension everything" finally started to make its way into the language with the introduction of "extension members". This new construct allows the creation of extension properties and indexers, as well as static methods, properties, and indexers for a type.
For example, a static extension method might look like the following:
string result = string.Random(42);
static class Extensions
{
extension (string)
{
public static string Random(int length) => new(Enumerable.Range(0, length).Select(_ => "abcdefghijklmnopqrstuvwxyz"[System.Random.Shared.Next(26)]).ToArray());
}
}This construct will be added to X10D in upcoming updates to add support for extension properties where appropriate, and static extension methods such as the above.
The language proposal for this feature can be found at https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/extensions
For implementation information, see: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
Sub-issues
Metadata
Metadata
Assignees
Labels
Projects
Status