Collection expressions, primary constructors, inline arrays and alias any type.
This release added 8 features, each with a before-and-after example.
Features in C# 12.0
- Alias any type - Use the alias directive to give names to types like tuples.
- Collection expressions - A short syntax for initializing collections.
- Default lambda parameters - Allow a lambda's parameters to specify default values.
- Experimental attribute - An annotation attribute to signal areas that are experimental.
- Inline arrays - Annotate a struct with InlineArray for optimized performance.
- Interceptors - Allow a method to declare it replaces another method.
- Primary constructors - Define a constructor and backing fields with a short syntax.
- ref readonly parameters - Allow parameters to be passed by reference without being modified.