sealed

suggest change

When applied to a class, the sealed modifier prevents other classes from inheriting from it.

class A { }
sealed class B : A { }
class C : B { } //error : Cannot derive from the sealed class

When applied to a virtual method (or virtual property), the sealed modifier prevents this method (property) from being overriden in derived classes.

public class A 
{
    public sealed override string ToString() // Virtual method inherited from class Object
    {
        return "Do not override me!";
    }
}

public class B: A 
{
    public override string ToString() // Compile time error
    { 
        return "An attempt to override"; 
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents