csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

[Proposal]: Target-typed implicit array creation expression `new[]`

Open 333fred opened this issue 11 months ago • 1 comments

Target-typed implicit array creation expression new[]

  • Specification: In the discussion for now
  • Discussion: https://github.com/dotnet/csharplang/discussions/8992

Summary

Allow KeyValuePair<string, string>[] array = new[] { new("key1", value1), new("key2", value2) };

Design meetings

333fred avatar Jan 06 '25 22:01 333fred

@jcouv I think we likely don't need to add this. We now hava target typed collection expressions, which work for arrays, and which provide a simpler and cleaner syntax for this: KeyValuePair<string, string>[] array = [new("key1", value1), new("key2", value2)];

Are you ok with me closing this out? Thanks!

CyrusNajmabadi avatar Feb 16 '25 00:02 CyrusNajmabadi