dotnet/csharplang

[API Proposal]: Collection Expressions and ```String.Empty```

TonyValenti opened this issue · 0 comments

Background and motivation

It would be really convenient if [] could be used as a shorthand for String.Empty.

API Proposal

I am not sure what is necessary to make this possible.

API Usage

public record Person {
  public string Name { get; init; } = [];
}

Alternative Designs

We could leave it as-is.
Also, someone could just use "" but that isn't as nice as [].

Risks

No response