C# Sealed

tutorial and example
tutorial and example

C# provides sealed keyword to apply restrictions on class and methods. If a class is defined as sealed then it can’t be inherited. If a method is defined as sealed then it can’t be overridden.

This is like final keyword of java. The main advantage of sealed class is that the third party vendor can’t develop any software by inheriting our logic. Sealed class is the last class in the hierarchy. A base class can never be a sealed class rather we can apply sealed keyword to a derived class.

Sealed Class Example:

Output

C# Sealed Method Example:

Output