Partial classes:
Partial classes are the classes which are dividing into no.of classes with the same name.partial classes can declared by the keyword”partial” .
partial classes are needed when we are doing big projects that we can develop the class by many developers at a time.
The compiler combines all parts of the partial class into one at complietime and exicute that class.
Example:
Public partial class Display
{
Console.writeline(“this is first part of partial class”);
}
Public partial class Display
{
console.writeline(“this is second part of partial class”);
}
A Partial class must contain atleast one partial method.
One partial method contains signature and other may contain implementation of the method.without implementation the compiler does n’t execute any partial method.
We must define these by ” partial” modifier
Partail methods can be static and they must have rerturn type.
Example:
Partial class P
{
Partial void print():
Partial class p
{
Partial void print()
{
Console.writeLine(“this is partial method”);
}
}
Public static void main()
{
P a=new P();
a.print();
}
}
No comments:
Post a Comment