Raw string literals, UTF-8 literals, generic attributes and the start of the ref-safety work with ref fields.
This release added 14 features, each with a before-and-after example.
Features in C# 11.0
- Auto-default structs - The compiler auto-initializes unassigned struct fields in constructors.
- Checked user-defined operators - Define checked versions of user-defined operators for overflow-aware arithmetic.
- Extended nameof scope - Use nameof with method parameters in attributes on that method.
- File local types - Restrict a type so it can only be referenced from the file it is declared in.
- Generic attributes - Allow attributes to take generic type arguments for strong typing.
- List patterns - Match arrays and lists against sequences of patterns.
- Newlines in string interpolations - Allow newlines inside interpolated string expression holes.
- Pattern match Span on string constants - Use pattern matching to compare a Span of characters against a string literal.
- Raw string literals - Allow strings containing newlines and quotes without escaping.
- ref fields and scoped ref - Allow ref fields inside ref struct types and control ref lifetime with scoped.
- Required members - Require members to be set by initializers.
- Static interface members - Allow members of an interface to be static abstract or virtual.
- Unsigned right shift operator - Shift the bits of an integer to the right ignoring the sign.
- UTF-8 string literals - Allow literal strings to be stored as UTF-8 instead of UTF-16.