E.g, if I have
namespace a
namespace b
{
class C...
class D...
}
So after compiling, in IL file, where's the namespace information? Do I get two classes named a.b.C and a.b.D where the class names is prefixed by the namespace name?
Or I get a namespace a.b in the assembly file and having class C/class D inside it, just like C# code?
The other two responses wrote something, so I have to write the opposite :-)
Let's say that Microsoft kept the foot in both camps... Reading the ECMA-335:
Page 114
But then even this ECMA standard uses freely the namespace concept:
And the IL language supports the
.namespace
instruction, that is equivalent to the namespace instruction of C# (this instruction is named in the ECMA standard but there are no examples. The ILASM compiles correctly this example and the decompiled code is what one would expect)...But note that the generated code is equivalent to not using
.namespace
and including directly the full name in the.class
:And then the
Type
class has aName
and aNamespace
properties. And theType
class (as a big piece of mscorlib) is integral to the good working of the CLR.So if the question is: is there an explicit namespace in a compiled .NET program? The response is "no". There is only fullnames.
If the question is: is there the concept of namespace in .NET (at any/all levels)? The response is "yes". It is present both in IL (source code level,
.namespace
), CLR (.NET API,Type.Namespace
), C# (the "main" language of .NET, used to write nearly all the .NET libraries) (namespace
).