Using the dynamic keyword tells the compiler to delay all analysis until run-time thus postponing the resolution and type checking of any member access of such object type.
The pseudo-type dynamic is also treated as System.Object but we do not need to use casting to invoke the methods in the System.Collections.Generic.List in our example. Accessing a member that do not exist in the single table inheritance will of course result to a run-time exception. Say, we try to invoke Length will result to:
As of now (if I'm not mistaken) Java does not support this kind of functionality yet. Personally, I love to see this kind of functionality too in Java =)
Overview of C# 3.0
- Lambda Expressions
- Extension Methods
C# 3.0 Extension Methods and the Java SE 7 Project