Thursday , February 21 2019
Home / Dot Net / C# / Sealed Class in c#

Sealed Class in c#

Sealed Class in C#:

Sealed class is used to define the inheritance level of a class.The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

When applied to a class, the sealed modifier prevents other classes from inheriting from it. In the following example, class B inherits from class A, but no class can inherit from class B.


Example 2:

In the following example, Z inherits from Y but Z cannot override the virtual function F that is declared in X and sealed in Y.

Important Points:

1.  A class, which restricts inheritance for security reason is declared, sealed class.
2.  Sealed class is the last class in the hierarchy.
3.  Sealed class can be a derived class but can’t be a base class.
4.  A sealed class cannot also be an abstract class. Because abstract class has to provide functionality and here we are
restricting it to inherit.

BackTo Classes

Print Friendly, PDF & Email

Give us your valuable feedback


About Murali

Hello everyone I am Software Developer having 3+ years of Experience in Microsoft Technologies and Others. My skills :-, C#,, SQL SERVER, web services, windows Service,Windows applications,HTML,CSS, JavaScript,JQuery,AnjularJs

Check Also

Studyclues_C#_Date Format

Date Formatting in C#

Date Formats in C#: Date Formatting in C# is a date and time format string …