docs
docs copied to clipboard
[C# 14-Tutorials]: New Feature - Extensions
Visual Studio release
17.14.p4
Link to speclet
Link to Pull request
New behavior
The new syntax supports extension containers to define extension members, including properties, indexers, and operators. It's generally binary compatible with the existing syntax, so upgrading should be smooth.
New tutorials
The additional extensions is a major new feature area. This one deserves two exploratory tutorials:
- Create new types of extensions, including properties, operators, and indexers.
- Migrate a set of extensions from the existing
thissyntax to the new syntax. This should include multiple extension containers (for different receivers) on the same static class. Include some generic specializations.
Scenario notes: Make a set of extensions to create a scenario based interface for a closed generic type. Something like Dictionary<DateOnly,WeatherForecast> or similar.
See this blog comment: https://devblogs.microsoft.com/dotnet/csharp-exploring-extension-members/?commentid=22057#comment-22057
This set of tutorials should include examples of extending a static class. Perhaps File or Directory, as shown in the blog comment, or Math would be a good set of scenarios.