The -ns option explicitly specifies the default namespace for all types that do not have an explicit namespace in their name.
-ns[: ]namespaceName
namespaceName | The name of the default namespace for all types declared in the application or class library. |
If The -ns option is not specified, then types that are not prefixed with a namespace and types that are not in a BEGIN NAMESPACE .. END NAMESPACE construct will be compiled as so-called global types.
The -ns option will work on the following types:
•Classes
•Interfaces
•Structures
•Vostructs
•Delegates
Namespace names must follow the same rules for program identifiers: they must begin with an uppercase or lowercase letter or an underscore, followed by zero or more uppercase or lowercase letters, numbers or underscores. All other characters are illegal, and will raise a compile-time error.
The default namespace is used for any declared types that do not have an explicit namespace in their name.
1.Open the project's Properties page.
2.Click the Language tab.
3.Change the value of the "Prefix classes with default namespace" property
4.Click here to see the property page
5.The build system will then generate a command line option that combines this property with the Default Namespace that is specified on the Application Tab of the project properties
When the following code is compiled without -ns compiler option the following types will be produced:
•Customer
•Point
•MyProject.Customer
•MyProject.Data.Customer
CLASS Customer
.
.
END CLASS
STRUCT Point
.
.
END STRUCT
ENUM CustomerType
.
END ENUM
CLASS MyProject.Customer
.
.
END CLASS
BEGIN NAMESPACE MyProject.Data
CLASS Customer
.
.
END CLASS
END NAMESPACE
If you compile the same code with a -ns:MyNameSpace option the following types will be produced:
•MyNameSpace.Customer
•MyNameSpace.Point
•MyProject.Customer
•MyProject.Data.Customer