6

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

bendewey
  • 38,870
  • 12
  • 96
  • 123

5 Answers5

15

No.

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

Guffa
  • 666,277
  • 106
  • 705
  • 986
  • 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
  • 100,265
  • 20
  • 154
  • 199
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
  • 321,763
  • 49
  • 514
  • 739
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,105
  • 24
  • 28
0

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

Aistina
  • 12,095
  • 12
  • 67
  • 87