Chapter 2: C #. NET Object-Oriented -- namespace, compilation unit, and assembly

Source: Internet
Author: User

C # organize various types of programs through namespace. An assembly is a physical container of these types and contains specific implementation code. All C # Have a namespace and a global namespace.

In addition to the name, C # contains many types of declarative space, such as the type declarative space and statement declarative space.

 

<1> Custom namespace

Use the keyword namespace to define the namespace:

Namespace name

{

// Code

}

 

◆ The namespace name can be a valid identifier of C #, or multiple identifiers can be connected using the operator (.) to indicate the depth of the space. For example:

◆ Do not use the same name for the namespace and class. You do not need to force the namespace name to be similar to the Set Name.

◆ If the namespace is missing, the namespace access permission is public, and no modifier can be used to declare the namespace.

◆ A namespace can contain other Members, such as other namespaces or types (classes, structures, interfaces, enumeration, and delegation ). For namespace type members, they have public or internal (default) access permissions.

◆ A namespace with the same name is regarded as the same namespace. For example, the following three pieces of code declare the same namespace.

 

Declare code 1: (use the "." namespace)

Namespace CloudCorwn. Software

{

Class ();

Class B ();

}

Declare Code 2: (using nested namespaces)

Namespace CloudCorwn

{

Namespace Software

{

ClassA ();

ClassB ();

}

}

Declaration Code 3:

Namespace CloudCrown. Software

{

ClassA ();

}

Namespace CloudCrown. Software

{

ClassB ();

}

In the preceding three Declaration Codes, the full qualified names of Class A and Class B are the same: CloudCrown. Software. A and CloudCrown. Software. B.

 

 

 

<2>. NET Framework class library namespace

Namespace provided by the. NET Framework class library

CATEGORY namespace Function
 
Component Model System. CodeDom source code document element and Structure Representation, and code compilation and processing
 
Implementation of the System. ComponentMode component, including authorization and design adjustment
 
Configure System. Configuration application Configuration data retrieval
 
Access and management of Data System. Data and Data sources
 
Standard-based support for Xml processing by System. XML
Bidirectional ing from System. Xml. Serialization object to Xml
 
Configuration and diagnosis of the System. Diagnostics application of the Framework Service
System. DirectoryServices accesses Active Directory. The classes in the namespace can be used together with any Active Directory Service Provider (for example, Internet Information Service (IIS ).
System. Messaging Microsoft Message Queue (MSMQ) Access Management, as well as message sending and receiving
System. Management uses Web-Based Enterprise Management (WBEM) standard service and application Management tools
System. ServiceProcess installation and execution of Windows-based service applications. Do not access specific services, such as Active Directory or Web Services
Events triggered by System. Timers Based on Time Interval or more complex time schedule
 
Globalization and localization System. Gloabization's support for code and resources globalization and Globalization
 
System. Resources resource management and access, including support for localization
 
A Collection of public task System. Collection objects (such as lists, queues, arrays, Kazakh Greek tables, and dictionaries)
Access and management of basic System. IO data streams, including file I/O, memory I/P, and independent storage
System. Tex character encoding and character conversion

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.