Question out of curiosity. I have successfully created a 300 levels deep namespace nesting. Visua studio happily suggest "a.a.a.a.a[...].a.theclass as a quick fix if i enter the class name buried below those layers of namespacing.
Does anyone know if there is an actual limit as for how deeply nested namespaces can be?
No case where I'd need it, just curious.
Two classes with the same name can be created inside 2 different namespaces in a single program. Inside a namespace, no two classes can have the same name.
There four types of namespaces in C#.
In C++, namespaces can be nested, and resolution of namespace variables is hierarchical. For example, in the following code, namespace inner is created inside namespace outer, which is inside the global namespace.
From documentation - Namespace Statement
You can declare one namespace within another. There is no strict limit to the levels of nesting you can declare, but remember that when other code accesses the elements declared in the innermost namespace, it must use a qualification string that contains all the namespace names in the nesting hierarchy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With