Namespaces vs. Assemblies

In .NET, code is organized into both assemblies and namespaces.

  • An assembly is a physical file containing a number of types (.exe or .dll)
  • A namespace is a logical grouping representing a parent name that various types belong to

An assembly can contain types belong to one or more namespaces.  Types belonging to a single namespace can be contained in a single assembly, or spread across multiple assemblies.

Code can reference types within another assembly after including a reference to that assembly in the current project.

Code can reference types in another namespace by using the full name of the type that includes the namespace, or with an using directive.

The example below shows two assemblies, both .DLL files, containing some types.  Each assembly contains types belonging to more than one namespace.  And each namespace shown is spread across both assemblies.

Ebook Download
View all
Learn
View all