Steve Fenton

C# Namespace Declarations

Unlike my recent article on Global Using Statement and Code Clues, the new namespace declarations have no trade offs and you should just auto-fix them in your whole project and move on with your life. Here’s how we do namespace before namespace declarations:

namespace Fenton.Sample.UI
{
    public class Example
    {

    }
}

…and here is how we declare namespaces with namespace declarations (no curly braces, no nesting, just a semi-colon):

namespace Fenton.Sample.UI;

public class Example
{

}

Less nesting, happy days.

Written by Steve Fenton on