O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic Dispatch

After the compiler has done its duty of generating code that will construct call site objects at runtime, all remaining work is left to the runtime. We already discussed in detail how call sites are built, but we haven’t yet discussed how the invocation of the dynamic operation is initiated. In the code that was generated for our running example, you can find the dispatch at the end:

private static void Add([Dynamic] object a, [Dynamic] object b){    // Code to ensure the call site objects are instantiated.    <Add>o__SiteContainer0.<>p__Site1.Target(        <Add>o__SiteContainer0.<>p__Site1, typeof(Console),        <Add>o__SiteContainer0.<>p__Site2.Target(            <Add>o__SiteContainer0.<>p__Site2, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required