I read C# spec and googled for it, but found nothing.
I am 99% sure there is no such feature like unit namespace directive in C#, but the question is: why? Are there idiomatic or technical reasons?
It is convenient, especially when most of our file consist of single namespace. Is there any feature requests or proposals out there? Maybe we can make one?
// with unit namespace
namespace Foo;
class Bar { ... } // Class Bar declared inside Foo Namespace
struct Baz { ... } // Baz is inside Foo too
// without
namespace Foo {
class Bar { ... }
class Baz { ... }
}
Or maybe there is a way to re-export global symbols?
I mean first you declare everything inside global namespace, and then
publish public symbols in selected namespace?
The deep nesting of C# code is one of the most annoying thing for me.
I really enjoyed C++ ability to forward declare even nested classes and then define them without even 1 extra level of nesting.
Thanks for your time.
you should never. At least I wonder why global namespace was added to the language. There could be interesting reasons that are not so obvious, at least for me. I want to know those reasons and you can provide this information, if you have an answer, of course.