Tuesday, 14 February 2012

Sealed Classes


Sealed classes are classes which are not inheritable.To prevent the class from inheritance we use “sealed” keyword before the class name.

If we use sealed keyword to any method that method can not be inheritable.

It can overrides the parent class method,but itself cannot be override in other classes.

Example:

Sealed class B

{

Public int i;

Public int j;

}

Class program

{

B s=new B();

s.i=345;

s.j=135;

console.writeline(“i={0},j={1}”,s.i,s.j);

}

No comments:

Post a Comment