What are sealed classes in C#?
Ask by Anonymous User
Updated 19 Sep 2020
We create sealed class when we want to restrict or prevent the class to be inherited. Sealed modifier is used to prevent derivation from a class. If we try to specify a sealed class as base class then a compile-time error occurs.
If we try to inherit sealed class then following error well be occure
class MyDerivedC: SealedClass {} // Error
The result is an error message:
'MyDerivedC' cannot inherit from sealed class 'SealedClass'.