You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature enables a type name to be omitted from static member access when it is the same as the target type.
This reduces construction and consumption verbosity for factory methods, nested derived types, enum values, constants, singletons, and other static members. In doing so, the way is also paved for discriminated unions to benefit from the same concise construction and consumption syntaxes.
type.GetMethod("Name",.Public|.Instance|.DeclaredOnly);// BindingFlags.Public | ...control.ForeColor=.Red;// Color.Redentity.InvoiceDate=.Today;// DateTime.TodayReadJsonDocument(.Parse(stream));// JsonDocument.Parse// Production (static members on Option<int>)Option<int>option=condition?.None:.Some(42);// Production (nested derived types)CustomResultresult=condition?new.Success(42):new.Error("message");// Consumption (nested derived types)returnresultswitch{.Success(varval)=>val,.Error=>defaultVal,};
Uh oh!
There was an error while loading. Please reload this page.
Target-typed static member lookup
Summary
This feature enables a type name to be omitted from static member access when it is the same as the target type.
This reduces construction and consumption verbosity for factory methods, nested derived types, enum values, constants, singletons, and other static members. In doing so, the way is also paved for discriminated unions to benefit from the same concise construction and consumption syntaxes.
Design meetings
The text was updated successfully, but these errors were encountered: