Thursday, March 08, 2012

How to stop Inheritance in C#

Use Sealed class to stop Inheritance. The following Example can give brief idea

Public  Sealed class A
{
Public int x=10;
Public int m()
{
return 20;
}
}

Public  Class B : A //compilation will give error
{
Public int y=10;
Public string m1()
{
return 10;
}

No comments:

Post a Comment