All about Sealed Class

This blog shows about Sealed Class

·         Sealed classes are used to restrict the inheritance feature of object oriented programming. 
·         Once class is defined as sealed class, this class cannot be inherited so we can't derive class.
·         Keywords: C# - Sealed , VB.NET - NotInheritable
·         If you have ever noticed, struct are sealed. You cannot derive a class from a struct.
·         A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class.
·         The best usage of sealed classes is when you have a class with static members.
·         Example - The Pens and Brushes classes of the System.Drawing namespace. The Pens class represent the pens for standard colors. This class has only static members. Pens.Blue represents a pen with blue color. Similarly, the Brushes class represents standard brushes. The Brushes.Blue represents a brush with blue color.

Next Recommended Reading What Is An Abstract Class?