C # Use of the partial keyword,

Source: Internet
Author: User

C # Use of the partial keyword,

C #2.0 introduces the concept of local types. The local type allows us to divide a class, structure, or interface into several parts, which are implemented in several different. cs files.

The local type applies to the following situations:

(1) The type is very large and should not be implemented in a file.
(2) A part of the code in a type is the code generated by the automation tool, and should not be mixed with the code we write.
(3) many people need to work together to compile a class.

Example:

Write the instance of class2 in the same namespace and add the keyword partial

 

Write the instance of class2 in the class3 class with the keyword partial

In main, we can see that it is compiled at the same time in each part.

 

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.