Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between namespace dot namespace and nested namespace?

Tags:

namespaces

c#

Is there any difference between:

namespace Outer.Inner
{
}

And

namespace Outer
{
    namespace Inner
    {
    }
}

in C#?


1 Answers

Assuming you don't put any other declarations or using directives in the Outer namespace, there's no difference at all.

Given that you would very very rarely declare members in multiple namespaces within a single file, I'd suggest using the first form - aside from anything else it saves a level of indentation. Note that "brace at the start of a new line" is a more conventional bracing style for C# though:

namespace Outer.Inner
{
    ...
}
like image 76
Jon Skeet Avatar answered Sep 15 '25 08:09

Jon Skeet