Showing posts with label THE SEALED KEYWORD. Show all posts
Showing posts with label THE SEALED KEYWORD. Show all posts

Monday, November 9, 2009

THE SEALED KEYWORD

This key word is used to prevent any class from inheriting. So if we want to fix a condition that no class should inherit from this class, then we can mention that class as sealed class.

public sealed class demo
{
public int a = 10;
public int b = 2;
public void add()
{
int c = a + b;
Console.WriteLine(c);
}
}
Now I cant inherit this class 'SINCE IT CONTAINS A KEY WORD SEALED'.