This is a project to show all the new C# 11 features coming in .NET 7 that are mentioned in the Microsoft Documentation.
The samples found in Program.cs are runnable using JetBrains Rider 2022.3+.
You can give things a try.
- File-scoped types
- Generic Math support
- Auto-default structs
- Pattern matching Span on a constant string
- Extended nameof scope
- Numeric IntPtr
- Utf-8 string literals
- Required Members
- ref fields and scoped ref
- Raw string literals
- Improved method group conversion to delegate
- Generic Attributes
- Newlines in string interpolation expressions
- List Patterns
- Warning Wave 7 (lot's of Roslyn-based warnings about code issues. Not shown in this project.)
Most of the features in C# 11 seem to be focused on low-level optimization and most folks will likely use a handful of these features, rather than "ALL OF THEM". Although, they will benefit from these features, as these are used internally by the .NET team to optimize hot path scenarios. We all win!
My favorite features that you'll likely use are:
- #10: Raw string literals (be sure to try it with Rider's language inject ๐จ๐ปโ๐ณ๐)
- #11: Improved method group conversion to delegate. (You're likely already using it now. So free perf!)
- #12: Generic Attributes. Heck to the Yeah!
- #8: Required Members (less boilerplate is always good)
- #14: List Patterns (This is a "maybe", and LINQ is also a good option)
In general, this is a good iterative update to the C# language but nothing as dramatic as LINQ, pattern matching, async/await or records. That's likely a good thing for many developers still trying to catch up.