Sealed Class in c#

Classes can be declared as sealed by putting the keyword sealed before the class definition. Sealed classes are used to restrict the inheritance feature of object-oriented programming.so The main purpose of a sealed class is to take away the inheritance feature from the user so they cannot derive a class from a sealed class. One of the best usages of sealed classes is when you have a class with static members. For example, the "Pens" and "Brushes" classes of the "System. Drawing" namespace.

Example:-

public sealed class textSealedClass
{
    // Class members here.
}

So when we defined a class with keyword “Sealed” then we don’t have a chance to derive that particular class and we don’t have permission to inherit the properties from that particular class.



Note:

1.      A class, which restricts inheritance for security reason is declared, sealed class.
2.      Sealed class is the last class in the hierarchy.
3.      Sealed class can be a derived class but can't be a base class.
4.      sealed class cannot also be an abstract class. Because abstract class has to provide functionality.