The dynamic Keyword in C# 4.0

One of the key features in .NET 4.0 is the support for reaching out to dynamically typed code (and object models representing data) from inside flagship languages such as C# and Visual Basic. The single syntactical presence of this feature in C# is the new dynamic keyword. When an object is typed as dynamic, the compiler emits code that causes all binding and dispatch operations to be deferred until runtime, instead of statically resolving them at compile time.

So, what’s binding and dispatching all about? Binding is essentially the act of figuring out the meaning of the code with regard to intended method calls, uses of members, and so on. To make this work at runtime, enough information about the intent of the ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.