C # partial class

Source: Internet
Author: User
Vs2005: Partial Class Classification
By Aillo

On October 22,200 8 AM

|
0 comments

| Previous
|
Next
| Edit

Partial class
, Category or distribution class. As the name implies, a class is divided into multiple parts. For example, a class has three methods. In VS 2005, three methods in the class are stored in three different. CS files.
Benefits:
1. A large project class can be divided into different blocks and transferred to differentProgramWrite and execute at the same time.
2. if the source is automatically generated by the system, you can add it with an independent partial class without having to change it to the original class.
3. When a class is large, you can use partial class for functional division, which is also a good classification method.


If you are developing a project's public function library, the richer the content for the public function library, the better, the better, but it is not possible to write it all at once, you need to accumulate at, then you can use partial
Class.
The class program is uploaded to the server or a specific directory.CodeCopy and paste it to the original program code to reduce unnecessary troubles.

Example
: Define the example class as partial
Class, define the three methods M1, M2, and m3 of this class in example1.cs, example2.cs, and example3.cs, and then in
Instantiate the example class in partialclass. aspx. CS and call the methods in the class.

// Example1.cs

Public partial class example
{
Public String M1 ()
{
Return "method 1 ";
}
}

// Example2.cs

Public partial class example
{
Public String m2 ()
{
Return "method 2 ";
}
}

// Example3.cs

Public partial class example
{
Public String m3 ()
{
Return "method 3 ";
}
}

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.