ExpandoObject,DynamicObject和dynamic之间的区别 [英] Differences between ExpandoObject, DynamicObject and dynamic
问题描述
System.Dynamic.ExpandoObject , System.Dynamic.DynamicObject
和动态
?
What are the differences between System.Dynamic.ExpandoObject
, System.Dynamic.DynamicObject
and dynamic
?
您在哪种情况下使用这些类型?
In which situations do you use these types?
推荐答案
dynamic
关键字用于声明应该迟到的变量。
如果要使用晚期绑定,对于任何真实或想象的类型,您使用动态
关键字,编译器执行其他操作。
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.
IDynamicMetaObjectProvider
界面
当您使用动态
关键字与 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
是一个简单的类,它允许您添加成员到实例并使用它们 dynamic
ally 。
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和dynamic之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!