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

No, but the first variant is the most used in c# code.
The second variant is what you'd have to write in C++ and I'm not sure I ever saw it in real c# code yet.


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
{
    ...
}

No difference whatsoever, those are the same thing, however the first one is more common.

Tags:

C#

Namespaces