Thursday, April 22, 2010
Dynamic Datatype in Csharp 4.0 is quit bit familier to Var Datatype. Deference betweet Var and Dynamic is VAR initialized on CompileTime and Dynamic initialized On Runtime. that's why Dynamic Data Type able define anonymous function on Compile Time.
Dynamic datatype allow to declare anonymous. this feature is really important when your work with com specially Silverlight .
To add Properties on runtime it was really big problem in C#. some of practice are available. like using IDictionary interface in C#.
but now in C#.4 by using dynamic datatype with ExpandoObject dynamic datatype you can add properties on runtime. Dynamic Type inherit IDictionary to maintain add dynamic properties.
Dynamic initialized its type on runtime like object but object initialized its type on compile time.
When we use ObjectType as parameter in overload object initialized on compile time. dynamic parameter accept as anonymous datatype and initialized its self on runtime for overload method.
Object class initialized complie time thats its not allow it to act anonymous Type
Dynamic datatype initialized runtime its allow it to act anonymous Type define its type on runtime according to type overload methad will call;
Dynamic datatype as function argument is little bit confusing in overloading cause is there is no other argument matched datatype then Dynamic will call.
Enjoy new dynamic datatype in c#4.0
By Usama whab khan