C# › Interfaces & Abstract Classes
How does the 'sealed' modifier interact with abstract classes and interface method overrides to control further extensibility?
AdvancedAnswer
'sealed' on a class prevents further inheritance entirely; on an OVERRIDING method (`public sealed override`), it prevents any FURTHER derived class from overriding that specific method again, even though the class itself remains inheritable — useful for locking down a critical piece of behavior in an otherwise still-extensible class hierarchy.
public abstract class Shape {
public abstract double Area();
}
public class Circle : Shape {
public sealed override double Area() => Math.PI * Radius * Radius; // no further overriding allowed
public double Radius { get; set; }
}
// public class SpecialCircle : Circle { public override double Area() { } } // Error: Area is sealedReal-world example Locking down a security-critical or invariant-preserving method so no further subclass can accidentally break its guaranteed behavior.