C# Feature โ Collection expressions
Overview
Section titled โOverviewโCollection expressions use [..]
to create arrays and collections and spread elements.
Introduced In
Section titled โIntroduced InโC# 12 (2023)
var a = new int[] { 1, 2, 3 };
int[] a = [1, 2, 3];int[] b = [..a, 4, 5];
Gotchas & Best Practices
Section titled โGotchas & Best Practicesโ- Requires target type; spreads copy elements.