virtual dispatch
Choosing which method body to run from the object's real type at run time, not from the declared type of the variable.
In more detail
Carrier c = new Overnight(); c.Quote(3m) runs Overnight's quote even though the compiler only saw a Carrier. It is the mechanism behind polymorphism.
Related terms
- virtual — The C# modifier for a member that has a working body a derived class may replace with override.
- override — The C# modifier that declares a replacement for an inherited virtual or abstract member, or for methods such as Equals and ToString.
- inheritance — Declaring one class or type as a specialised version of another, so it receives the parent's members and can be used wherever the parent is expected.
Taught in
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices