When developers want to place their classes in the specified. Net namespace, they need to use namespace.
Namespace
By default, every VB. NET applicationProgramIn a default namespace, this namespace is often referenced as an absolute namespace location of the application. Visual Studio. Net sets it to the top-level namespace and automatically assigns it a name that matches your project name.
When you create a new windowsapplication1 project (the default name is used when you create a new project for the Windows Application in Visual Studio. NET), The namespace of windowsapplication1 is set. To modify the project namespace, open the Project Properties window and modify the rootnamespace field in the application tag. If you want to set a namespace for an existing namespace, for example. windows. if you set namespace for forms, make sure that the class name does not conflict with other class names defined in the namespace.
Naming Conventions
When a. NET application (exe) is generated, the name you select for namespace is not very important, because namespace only exists in your program. The namespace of both windowsapplication1 applications does not conflict with each other. If you generate.. net library (DLL), it will be allocated to people outside your team or organization. At this time, make sure that the namespace you select does not conflict with other namespaces.
For namespace naming conventions, Microsoft generally recommends that you use names related to your company's product names.
Configuration
In addition to absolute positions, you can use relative namespace to place your class in a larger absolute namespace. When you add a class to the project, it appears in the absolute namespace position.
Class class1
End Class
If your project uses windowsapplication1 as its absolute namespace, this class will appear in the name of windowsapplication1.class1.
In relative positions, you can insert a new namespace between the absolute position and the class:
Namespace generalapplications
Class class1
End Class
End namespace
In this case, the complete reference of class1 is windowsapplication1.generalapplications. class1.
Keywords
The namespace keyword may contain the names of multiple namespaces in different periods. Another thing to remember is that namespace may also be nested.