Skip to content

C# Feature โ€“ Collection expressions

Collection expressions use [..] to create arrays and collections and spread elements.

C# 12 (2023)

var a = new int[] { 1, 2, 3 };
int[] a = [1, 2, 3];
int[] b = [..a, 4, 5];
  • Requires target type; spreads copy elements.