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.