Does everything in a single namespace compile into its own assembly?
5 Answers
No.
You can have several namespaces in an assembly, and you can use the same namespace in different assemblies.
- 666,277
- 106
- 705
- 986
-
2E.g. System.dll and System.Core.dll both contain types in both the System and System.Collections.Generic namespaces (amongst many others). – Richard Mar 20 '09 at 23:16
No, you can have multiple namespaces within an assembly. In VS terms, you can think of an assembly as a project. Each project within a solution, gets compiled into it's own assembly. Within an assembly though, you can have multiple namespaces.
- 100,265
- 20
- 154
- 199
Assemblies and namespaces have nothing to do with each other except that there's a generally used convention that the full names of classes in an assembly will match the assembly name (in some way).
It's strictly a naming convention - as Guffa said, assemblies can define classes for more than one namespace and the classes that exist in a namespace can come from more than one assembly.
- 1
- 1
- 321,763
- 49
- 514
- 739
Classes are organized in Namespaces just to keep a naming separation and organization. Think of namespaces as "folders" that contain one or more classes, and that might be defined in one or more assemblies (DLLs).
more info: https://stackoverflow.com/a/20056937/579381
If you're asking if each namespace results in a seperate assembly, then no. One assembly can contain multiple namespaces.
- 12,095
- 12
- 67
- 87