sealed class  in C#

s

The major goal of a sealed class  in C# is removing the inheritance feature from it .

as a result developers will not be able to derive other class from it.

Sealed classes may be a good choice if you’re developing a class library and wish to prevent developers from deriving your classes.

When you place “sealed” keyword before the class declaration you prevents other classes from inheriting from it

Syntaxt:

Example of sealed class :

Sealed methods

Sealed methods cannot be overridden. However, direct child class can only override the method, class that inherited the child class that cannot override the sealed methods. Basically in multilevel inheritance sealed keyword prevent the methods from multiple overridden. If you want to make a method as sealed then you have to put sealed keyword in child class before override and make it virtual in base class.

Syntax:

Example

About the author

Badran Yahyaoui

Hello! I’m Badran, diligent & dedicated software engineer with 5+ years experience in financial & marketing applications .

By Badran Yahyaoui

Badran Yahyaoui

Hello! I’m Badran, diligent & dedicated software engineer with 5+ years experience in financial & marketing applications .

About me

Hello! I’m Badran, diligent & dedicated software engineer with 5+ years experience in financial & marketing applications .
I am passionate about building excellent application that improves the lives of those around me. I specialize in creating softwares & applications for clients ranging from individuals and small-businesses all the way to large enterprise corporations.
What would you do if you had a software expert available at your fingertips?