C# Sealed Keyword

Updated on     Kisan Patel

Sealed classes are classes that cannot be inherited. You can use the sealed keyword to define a class as sealed class.

For Example,

sealed class MyClass {
...
}

The following code snippet shows how to define a sealed class.

sealed class A
{
    ...
}

If we will tries inherit another class B with A.

class B : A
{
    ...
}

The compiler will generate the following error.

c-sharp-sealed-class-example


C#

Leave a Reply