Sealed Class in C# with Example

Sealed Class in C# with Example
Rating: 5 - 1 Votes

Sealed Class in C# with Example

Sealed Class in C# with Example

Sealed Class in C# with Example

If you want to prevent any class to be used as a base class in inheritance chain, you can mark that class sealed using sealed keyword.  Sealed class is normally a last class in the inheritance chain.  A sealed class can inherit from other class or interface, but other classes cannot inherit from it.  Apart from this condition, a sealed class behaves like a normal class.

The following code is just for demonstration purpose and it would not compile.