Is it always necessary to follow the sealed
keyword with override
in the signature of a method like the below code:
public sealed o
Well, it technically is possible .... however, the solution is in my option kinda dirty.
Imagine having a class A
(either in your code base or an external library):
public class A
{
public virtual void M () { /* implementation */ }
}
You could define an (abstract) class B : A
as follows:
public class B : A
{
public sealed override void M() => base.M();
}
Any class C : B
would not be able to override A.M
as you have sealed the method (even though you made no semantic changes).