什么时候应该在 c# 4.0 中使用 dynamic 关键字? [英] When should one use dynamic keyword in c# 4.0?

查看:14
本文介绍了什么时候应该在 c# 4.0 中使用 dynamic 关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候应该在 c# 4.0 中使用 dynamic 关键字?....... 任何在 c# 4.0 中使用 dynamic 关键字的好例子来解释它的用法....

When should one use dynamic keyword in c# 4.0?.......Any good example with dynamic keyword in c# 4.0 that explains its usage....

推荐答案

Dynamic 应该只使用当不使用它很痛苦时.就像在 MS Office 库中一样.在所有其他情况下,应避免使用,因为编译类型检查是有益的.以下是使用动态的好情况.

Dynamic should be used only when not using it is painful. Like in MS Office libraries. In all other cases it should be avoided as compile type checking is beneficial. Following are the good situation of using dynamic.

  1. 从 Silverlight 调用 javascript 方法.
  2. COM 互操作.
  3. 也许可以在不创建自定义类的情况下阅读 Xml、Json.

这篇关于什么时候应该在 c# 4.0 中使用 dynamic 关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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