Bohdan
Bohdan

Reputation: 2027

Using using with nested namespaces

Is there any reason, why

new N1.N2.N3.C();

would compile, but

using N1.N2;
...
new N3.C();

would not?

EDIT

Class C is defined in another referenced assembly like this:

namespace N1.N2.N3
{
   class C
   {
   }
}

Upvotes: 4

Views: 243

Answers (2)

Unsliced
Unsliced

Reputation: 10552

Because namespaces need to be either fully qualified in their use or via a using. An object's definition either has a fully qualified namespace, an alias or nothing - in which case the full namespace must have a using.

N3 is not a full namespace - it's just a part of one.

Upvotes: 2

TJHeuvel
TJHeuvel

Reputation: 12608

Because you arent including the N3 namespace, thus C isnt found.

Upvotes: 0

Related Questions