Sealed Class and Sealed Members
Sealed classes are the reverse of abstract classes
It is not possible to utilise a sealed class as a base class. It cannot therefore also be an abstract class.
When to use Sealed Class
This, is used to stop a developer to extend a class or override a method accidentally.
Use Sealed modifier is used to declare a class as sealed
One of the best uses of sealed classes is when you have a class with static members.
When you want to prevent other developers from creating a derived class (or restrict the class to be inherited) and modifying the behavior of the class in unintended ways.
If you are designing a class for a specific use case and you don't expect it to be used as a base class for other classes, you can use the sealed keyword to prevent other developers from creating a derived class that could break the intended behavior of the class.
Characteristics of a Sealed Modifler
1. you can apply the sealed modifier to a property or method that overrides a virtual property or method
2. The sealed properties and methods seal their implementations to prevent overriding
3. Abstract methods cannot be used in a sealed class.
4. In the inheritance hierarchy, it must be the bottom-most class.
5. Sealed class purposely used to avoid inheritance.
6. The sealed keyword used with methods, classes, properties, and instance.
Example #1 Sealed Class
When a method is considered sealed, it means that it belongs to a parent class and cannot be overridden by a child class.
Example #1 Sealed Members