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

Deferred Overload Resolution

In the preceding example, things are getting more interesting at runtime. As you will see later, a call site object is hiding behind the compiled code for the Math.Max call. Now it’s totally possible this code path gets hit multiple times, with different runtime types for a. One time, a may happen to be an Int32, so Math.Max really has two Int32 inputs. The runtime magic of dynamic figures out the best overload is Math.Max(int, int) and causes the call to be dispatched to that target method.

When another trip through the code is made with the runtime type of a being an Int64, the call site is now faced with an Int32 and an Int64. Again, in concert with the runtime binder, it figures out the best overload for the call ...

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