ExpandoObject,DynamicObject和动态之间的差异 [英] Differences between ExpandoObject, DynamicObject and dynamic

查看:590
本文介绍了ExpandoObject,DynamicObject和动态之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 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接口允许类利用其后期绑定行为​​的控制。
当您使用动态关键字与 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 dynamically.
DynamicObject is a more advanced implementation which can be inherited to easily provide customized behavior.

这篇关于ExpandoObject,DynamicObject和动态之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆