4

C# Namespace Declarations

 2 years ago
source link: https://www.stevefenton.co.uk/2021/09/c-namespace-declarations/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK