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)
Before
Section titled “Before”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.