General understanding C #(20. combination, namespace, and access level)

Source: Internet
Author: User

20. combination, namespace, and access level

In C #, you can organize components (class, structure, Delegate, enumeration, etc.) in your source code into files, namespaces, and combinations.

The namespace is just a sweet syntax for long class names. For example, if you do not need to write Genamics. WinForms. Grid like this, you can declare and wrap the Grid class:

Namespace Genamics. WinForms

{

Public class Grid

{

//....

}

}

For a class that uses the Grid, you can use the using keyword to import [: using Genamics. WinForms] without using its complete class name Genamics. WinForms. Grid.

The combination is an exe or dll compiled from the project file .. When running. NET, you can use configurable features and version rules to create them in the combination, which greatly simplifies deployment-you do not need to write the registry, as long as you copy the combination to the relevant directory. The combination body can also form a type boundary to solve the Class Name Conflict problem. Multiple versions of the same combination can coexist in the same process. Each file can contain multiple classes and multiple namespaces. A namespace can span several combinations. In this way, the system will have a greater degree of freedom.

C # has five access levels: private, internal, protected, internal protected, and public ]. Private and public are the same as Java. In C #, the access level is not specified as private, rather than the package range. Internal access is confined to the combination rather than the namespace (which is more similar to Java. Internal protected is equivalent to Java's protected. Protected is equivalent to Java's private protected, which has been discarded by Java.

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.