When creating a new project in VS 2022 with .NET 6, following new features are added automatically:
- Top-Level Statements
- Implicit Usings and Nullable References
Is there a way to create a .NET 6 project
without top-level-statements (a workaround other than creating a .NET 5 project & changing project type to .NET 6)
with implicit usings & nullable references disabled (without editing the project file each time after project creation)
CodePudding user response:
Targetting the .net5 framework and editing the project file is the official way to use the old program style.
Nullable reference types - keep them on
I suggest keeping nullable reference types on. I'd echo Embracing nullable reference types and say that all new code should use it. Here's the original statement:
When .NET 5 rolls around, if we feel the nullable rollout phase has been a success, I could see us turning the feature on by default for new projects in Visual Studio. If the ecosystem is ready for it, there is no reason why any new code should ignore the improved safety and reliability you get from nullability annotations!