File-scoped namespaces, global usings, record structs and interpolated string handlers.
This release added 10 features, each with a before-and-after example.
Features in C# 10.0
- Caller argument expressions - Allow methods to capture the code passed in an argument at compile time.
- Constant interpolated strings - Allow constant strings to use string interpolation.
- Extended property patterns - Allow property sub-patterns to reference nested members.
- File-scoped namespaces - Allow a namespace to be specified for an entire file to reduce indentation.
- global using directives - Specify common using directives to be used across all source files.
- Interpolated string handlers - Replace interpolated string expressions with handlers to optimize performance.
- Lambda improvements - Add attributes, explicit return types, and natural type inference to lambdas.
- Parameterless struct constructors - Allow structs to have parameterless constructors.
- Record structs - Allow records to be value type structs.
- with expressions for structs - Create modified copies of structs and anonymous types using with expressions.