How to get Visual Studio to use File Scoped namespaces by default
03:31 24 Nov 2023

One of the changes to .Net, which cam in with .Net 6 I think, is the use of file scoped namespaces to reduce nesting.

I have created a solution containing .Net 8 project.

When I create a class using visual studio the default is to still nest the class within the namespace rather than use file scoped namespaces.

I expected it to default to file scoped namespaces as it was a .Net 8 project.

Is there a setting somewhere I need to alter?

.net visual-studio