ExpandoObject,DynamicObject和动态之间的差异 [英] Differences between ExpandoObject, DynamicObject and dynamic
问题描述
什么是 System.Dynamic.ExpandoObject
, System.Dynamic.DynamicObject
和<$ C $之间的差异C>动态?
在哪些情况下,你使用这些类型?
In which situations do you use these types?
推荐答案
在动态
关键字来声明变量,应该是后期绑定。
如果你想使用后期绑定,任何真实或想象的类型,可以使用动态
关键字和编译器没有休息。
The dynamic
keyword 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 dynamic
keyword and the compiler does the rest.
在使用动态
关键字与正常的实例进行交互,在DLR进行后期绑定调用该实例的常用方法。
When you use the dynamic
keyword to interact with a normal instance, the DLR performs late-bound calls to the instance's normal methods.
的<一个href="http://msdn.microsoft.com/en-us/library/system.dynamic.idynamicmetaobjectprovider.aspx"><$c$c>IDynamicMetaObjectProvider$c$c>接口允许类利用其后期绑定行为的控制。
当您使用动态
关键字与 IDynamicMetaObjectProvider
实施交互时,DLR调用 IDynamicMetaObjectProvider
方法和对象本身决定该怎么做。
The IDynamicMetaObjectProvider
interface allows a class to take control of its late-bound behavior.
When you use the dynamic
keyword to interact with an IDynamicMetaObjectProvider
implementation, the DLR calls the IDynamicMetaObjectProvider
methods and the object itself decides what to do.
在 ExpandoObject
和 DynamicObject
类 IDynamicMetaObjectProvider
。
ExpandoObject
是一个简单的类,它允许你将成员添加到一个实例,并使用它们动态
的盟友。< BR>
DynamicObject
是可以继承轻松地提供定制化特性的更高级的实现。
ExpandoObject
is a simple class which allows you to add members to an instance and use them dynamic
ally.
DynamicObject
is a more advanced implementation which can be inherited to easily provide customized behavior.
这篇关于ExpandoObject,DynamicObject和动态之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!