views:

142

answers:

3

When should one use dynamic keyword in c# 4.0?.......Any good example with dynamic keyword in c# 4.0 that explains its usage....

A: 

Dynamic should be used only when not using it is painful. Like in MS Office libraries. In all other cases it should be avoided as compile type checking is beneficial. Following are the good situation of using dynamic.

  1. Calling javascript method from Silverlight.
  2. COM interop.
  3. May be reading Xml.
Amitabh
A: 

I've been trying to answer such questions on C# FAQ blog: http://blogs.msdn.com/csharpfaq/archive/tags/dynamic/default.aspx

Alexandra Rusina