The C # namespaces

Namespace designed to provide a way to make a group name and other names separated. In a namespace declaration in the name of the class with another class named the same namespace declarations do not conflict.
Define a namespace : namespace keyword namespace definition is based on the start, followed by a namespace name. Using keyword: show program using a given namespace name.
Nested namespace : namespace can be nested, that is, you can define another namespace within a namespace.
Namespace Screenshot
Namespace : default name is based on the current project.

Common namespace :
the Using System: contains the basic classes defined data types, events, event handlers, etc.
Using System.Data: namespace contains classes and provide data access functionality.
Using System.IO: contains the data stream associated with the reader functionality.
Using System.Windows.Forms: form class contains the tools needed for Windows Forms development.
Using System.Web: contains all website development related to namespaces and classes.

In the same project, reference the namespace:

01
02
03

In different projects, reference a namespace:

01
Click References, select Add Reference. Select an item, add it.
02

Reference system's own namespace:

Click References, select Add Reference. Select Programs, then add it.
01

Published 12 original articles · won praise 18 · views 515

Guess you like

Origin blog.csdn.net/weixin_42132959/article/details/103971787