How to Prevent the Class from Inheriting in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

You can use the keyword “sealed” in C# to prevent the user from inheriting the class.

Below is a class that is marked as sealed and is not inheritable.

How to Prevent the Class from Inheriting in C# ?

sealed class Employee
{
    public string Name {get;set;}
}
%d bloggers like this: