Namespaces

Delphi units provide the capability to physically group logical types into separate files. Namespaces take this grouping further by proving a way to hierarchically contain Delphi units. This fits well within the .NET way of doing this because native NET types are already grouped in this manner. The benefits to this are

  • Namespaces can be nested to form a logical hierarchy of types.

  • Namespaces can be used to disambiguate types with the same name.

  • Namespaces can be used to disambiguate units with the same name that reside in different packages.

Namespace Declaration

A project file declares its own default namespace, which we call the project default namespace. Therefore, a project declared as

program MyProject.MyIdeas;

creates the namespace ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.