Show/Hide Toolbars

XSharp

Purpose

The BEGIN NAMESPACE and END NAMESPACE keyword pairs declare a scope and add a namespace prefix to all types declared inside this scope.

 

Syntax

 BEGIN NAMESPACE namespaceName  
         typeDeclarations  
         namespaceDeclarations
 END NAMESPACE

Arguments

 

namespaceNameThe name of the namespace being declared.
typeDeclarations One or more type declarations (CLASS, STRUCTURE, etc.).
namespaceDeclarations Zero or more namespace declarations.

 

 

Any types declared within a namespace scope have the namespace name prepended to the type name. For example, a class named "MyClass" that is declared within a namespace named "MyNamespace" will have a type name of "MyNamespace.MyClass".

 

Types declared outside any namespace scope are declared in the "global" or "unnamed" namespace.

 

BEGIN NAMESPACE ... END NAMESPACE blocks can be nested to any depth. Nested namespace names have the enclosing namespace name prepended to it, separated by a period.

 

The same namespace name may be declared multiple times in the same or different files. The BEGIN NAMESPACE and END NAMESPACE statements do not cause any code to be generated, they simply affect the name of any types declared within the namespace block.

 

using directives that appear within a namespace are only in effect within the enclosing namespace block, and any nested namespace blocks.

Compatibility Note:

Code migrated from Visual Objects to Vulcan.NET using the Transporter is not placed within any BEGIN NAMESPACE ... END NAMESPACE blocks, because Visual Objects has no concept of namespaces. Therefore, all classes in transported code are in the global or "unnamed" namespace and do not have a namespace name prepended to them.

 

Example

 
BEGIN NAMESPACE a
 
  CLASS one           // actual type name is 'a.one'
     ...
  END CLASS
 
  BEGIN NAMESPACE b   // the namespace name is 'a.b'
 
      CLASS two       // actual type name is 'a.b.two'
         ...
      END CLASS
 
  END NAMESPACE
 
END NAMESPACE
 
CLASS three           // actual type name is 'three'
  ...
END CLASS