C# 10: File-Scoped Namespaces

The era of indentation hell is over. C# 10 introduces File-Scoped Namespaces.

// Old Way
namespace MyCompany.MyApp
{
    public class MyClass 
    {
    }
}

// New Way (One less level of indentation!)
namespace MyCompany.MyApp;

public class MyClass
{
}

This seems minor, but combined with Global Usings, it saves 5-10 lines of vertical space per file.


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.