C# Sealed Class

In this article we will discuss about what is Sealed Class and how it will be implemented.
  • 3844

We know that a public or internal Class can be inherited by any other class and by inheriting the class we can access its properties within another derived Class in C#. If we do not want a Class to be inherited by another Class in C# then C# introduces us the concept of Sealed Class. A Class can be declared as Sealed Class by using Sealed keyword followed by the access modifier and class name. If we will try to inherit a sealed Class then the compiler will generate an error that you can't inherit the Sealed Class.

Here is the Complete Program:

 Image3.jpg

In the above figure it is clear that Class A is declared as a Sealed Class and if another Class i.e. B is trying to inherit it a compiler is giving the error that class B cannot inherit the Class A.

Further Readings
 
You may also want to read these related articles.

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.