Skip to content

Virtual Functions

Mario edited this page Sep 6, 2024 · 1 revision

You can mark a method as overrideable with the virtual keyword.

public virtual void OverrideableMethod() { }

// Then, in the child class:
public override void OverrideableMethod() { }

You can call the parent method with:

base.OverrideableMethod();

You can prevent a method from further being overridden by sealing it.

public override sealed void OverrideableMethod() { }
Clone this wiki locally