class X {
sealed protected virtual void F() {
Console.WriteLine("X.F");
}
sealed void F1();
protected virtual void F2() {
Console.WriteLine("X.F2");
}
}
In the above code there is compile time error :
X.F()' cannot be sealed because it is not an override
X.F1()' cannot be sealed because it is not an override
Does it mean we can only apply the sealed
keyword whey we have to override some methods?
Well, sealed keyword prevents method from being overriden, and that's why it doesn't make sence
virtual
instead of declaringvirtual sealed
.So the only option is
override sealed
which means override, but the last time: