Partial Class:
This special type
of class called "Partial Class" is introduced with .Net Framework
2.0. Partial Class allows its members – method, properties, and events – to be
divided into multiple source files (.cs). At compile time these files get
combined into a single class.
Partial Class is denoted by the keyword partial.
Partial Class is denoted by the keyword partial.
Some do's and don'ts about partial class:-
• All the parts of a partial class must be prefixed with the keyword partial.
• Accessibility, signature etc. must be same in all parts of the partial class.
• You cannot sealed one part of the partial class. In that case entire class in sealed.
• If you define any part of the partial class abstract, entire class will become abstract.
• Inheritance cannot be applied to a part of partial class. If you do so, it applies to entire class.
Example:
public
partial class myPartialClass
{
public
void firstMethod()
{
//
code…
}
}
public partial class myPartialClass
{
public
void secondMethod()
{
//
code…
}
}
0 comments:
Post a Comment