Using Namespaces with Delphi In Delphi, a unit is the basic container for types. Microsoft's Common Language Runtime (CLR) introduces another
layer of organization called a namespace. In the .NET Framework, a namespace is a conceptual container of types.
In Delphi, a namespace is a container of Delphi units. The addition of namespaces gives Delphi the ability to access
and extend classes in the .NET Framework.
Unlike traditional Delphi units, namespaces can be nested to form a containment hierarchy. Nested namespaces
provide a way to organize identifiers and types, and are used to disambiguate types with the same name. Since they
are a container for Delphi units, namespaces may also be used to differentiate between units of the same name,
that reside in different packages.
For example, the class
MyClass
in
MyNameSpace
, is different from the class
MyClass
in
YourNamespace
. At
runtime, the CLR always refers to classes and types by their fully qualified names: the assembly name, followed by
the namespace that contains the type. The CLR itself has no concept or implementation of the namespace hierarchy;
it is purely a notational convenience of the programming language.
The following topics are covered:
Project default namespaces, and namespace declaration.
Namespace search scope.
Using namespaces in Delphi units.