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 ";
}
}