6

Does everything in a single namespace compile into its own assembly?

bendewey
  • 39,709
  • 13
  • 100
  • 125

5 Answers5

15

No.

You can have several namespaces in an assembly, and you can use the same namespace in different assemblies.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • 2
    E.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
8

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.

BFree
  • 102,548
  • 21
  • 159
  • 201
2

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.

Community
  • 1
  • 1
Michael Burr
  • 333,147
  • 50
  • 533
  • 760
0

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

Community
  • 1
  • 1
Ayub
  • 2,345
  • 27
  • 29
0

If you're asking if each namespace results in a seperate assembly, then no. One assembly can contain multiple namespaces.

Aistina
  • 12,435
  • 13
  • 69
  • 89