Published On Dec 1, 2023
Initializing arrays is C# has always been easier than initializing other collections. In C#12 we can do it all in the same way.
Source code available at: https://github.com/JasperKent/Collect...
Related videos:
- C# 9 Fit and Finish • C# 9 - Fit and Finish
- Implementing IEnumerable • Implementing IEnumerable
- C# 12 Primary Constructors • C# 12 Primary Constructors
- Stackalloc and Spans • Stackalloc and Spans
Topics include:
- Brief history of array initialization
- C#3 collection initializers
- Creating empty collections
- C#12 collection expressions
- Problems initializing Dictionaries
- Initializing multidimensional arrays
- The C#12 spread operator (..)
- Using collection expressions and spread with custom collections
- Initializing with the CollectionBuilder attribute