-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Milestone
Description
Case Declarations
- Specification: Case Declarations
- Working group folder: Discriminated Unions
- Discussion: [Discussion] Case Declarations #9502
Summary
A case declaration is a shorthand syntax for declaring a nested case of a closed type.
It infers much of what it is from context.
public closed record GateState
{
case Closed;
case Locked;
case Open(float Percent);
}When used within a record declaration, it is the equivalent of writing:
public closed record GateState
{
public sealed record Closed : GateState;
public sealed record Locked : GateState;
public sealed record Open(float Percent) : GateState;
}Design meetings
Reactions are currently unavailable