Mark the class as sealed.
Code:
sealed class MyClass
{
...
}
Structs are inherently sealed
Prevent Overriding of a Single Method
Put sealed as part of the method or property definition.
Code:
class ParentClass
{
public virtual void MyFunc() { }
}
class ChildClass : ParentClass
{
//seal base class function into this class
public sealed override void MyFunc() { }
}
class GrandChildClass : ChildClass
{
//yields compile error
public override void MyFunc() { }
}