What are the differences between System.Dynamic.ExpandoObject, System.Dynamic.DynamicObject and dynamic?
In which situations do you use these types?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
dynamickeyword is used to declare variables that should be late-bound.If you want to use late binding, for any real or imagined type, you use the
dynamickeyword and the compiler does the rest.When you use the
dynamickeyword to interact with a normal instance, the DLR performs late-bound calls to the instance’s normal methods.The
IDynamicMetaObjectProviderinterface allows a class to take control of its late-bound behavior.When you use the
dynamickeyword to interact with anIDynamicMetaObjectProviderimplementation, the DLR calls theIDynamicMetaObjectProvidermethods and the object itself decides what to do.The
ExpandoObjectandDynamicObjectclasses are implementations ofIDynamicMetaObjectProvider.ExpandoObjectis a simple class which allows you to add members to an instance and use themdynamically.DynamicObjectis a more advanced implementation which can be inherited to easily provide customized behavior.