C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Incorrect single/multiple dispatch usage

Chapter 14: Dynamic binding in a static language: P428, section 14.3.3

Created: 10/25/2016
Last updated: 10/25/2016
Severity: Technical error

Beginning on page 428, I talk about single/multiple dispatch, but I don't actually show multiple dispatch, as the implementation is only ever chosen based on a single execution-time type.

Real multiple dispatch - which dynamic typing in C# is entirely capable of - would require an example where either the types of both target of the call and at least one argument, or just multiple arguments, were required to dispatch the method.

It wouldn't be true to call this static vs dynamic dispatch, as C# has always had dynamic dispatch - but only on the type of the target of the call. Dynamic typing in C# 4 adds the ability for overload resolution to be performed dynamically based on execution-time argument types as well as the implementation of the chosen signature based on the execution-time target type.