Sealed Class

Sealed class is a class that cannot be inherited by any class but can be instantiated. It is often used to encapsulate a logic that needs to be used across the program but without any alteration to it. In order to declare a sealed class we need to used Sealed keyword before class.

CODE

EG 1 . Creating a class called sampleClass and inheriting a sealed class Rectangle to it.

sealed class Rectangle {
    public double length, width;
    public double Area() {
        return length * width;
    }
}

class sampleClass : Rectangle {

}