Saturday, October 20, 2012

Difference between Sealed and Partial class in C#.Net

Sealed Class:
1.Sealed is a keyword
2.Sealed class are not inheritable
3.When ever a class is providing full functionality as per the requirements,then that class need to be declared as sealed

Partial class:
1.Partial keyword can be used with classes and interfaces
2.When a class or interface need be written in multiple locations with same name then those class or interfaces need to be partial

Here i will given an example on Partial class
//Open windows form project.Then place a button
//Code in General declaration
Interface test
void read();
void print();
Partial class testchild:Test
public void read()
Partial class testchild
public void print()

//Code for button click
testchild tc=new testchild();;
test t=new test();;
Post a Comment