It seems like the confusion here is about the conceptualization of what is namespace
.
A namesapace
is a surname for a type (a class for example). If you have namespace X
and class Y
. It's the same as saying that you declared class X.Y
.
Import
When you put import X
, you are just telling the compiler that it should search for types (classes for example) used in your code in that file (technically in any code that is below the import
directive). So the compiler understands that you have used the Y
class in your code and have import X
. Everything will work because it finds the class, it has the full class name.
When you are going to use a member of a class you can refer to a method Z as X.Y.Z()
and do not use import
. This way it becomes clear that namespace
is just a last name of the class.
Namespace is not encapsulation
So you can have% s of% s repeated everywhere in your software. He does not compartmentalize anything. In .Net this compartmentalization occurs through the assembly . That is, roughly speaking, the equivalent of namespace
of Java. In fact, package
also organizes the surname of the type at the same time. The surname of the type is the same as the package where it is.
A package
has path , as well as assembly . But in .Net this does not matter in code. The assembly is inserted into the project externally to the code. C # and VB.Net have separated the concept of code pack and type grouping (classes, enums, etc.).
The package
transcends namespace
and is orthogonal concepts. Effectively when the code is compiled, assembly
disappears and only one type with a surname is in the code.
Disambiguation
If your code has the same class in namespace
s different, you need to use the full name (you can even use namespace
to create an alias of import
to facilitate).
But if you have the same class in the same namespace
, some error should occur. So much so that the only way to have twice the same name for a class is to use namespace
which indicates that in different sources you have the same complementing class. But it does not seem to be your case.
Assembly X namespace
The fact that there is an assembly and a partial
with the same name, is just a coincidence. These are very different things. The assembly is referenced in the project (it may be that the problem is there).
Your case
If you took the% s of% s and no problem happened, you were not using any type contained in the% s 'imported'% s. If you change the name of namespace
that is really needed, it will give error.
It is possible that some of these files that you say have duplicate classes are not being referenced in the project. It could be that it was rubbish, test, I do not know, that the previous programmer left there without necessity.
If you need more specific information, we need to better understand how your project and its code are structured.
For more information you can read this and this response.