C#4动态关键字 - 为什么不? [英] C#4 dynamic keyword - why not?

查看:127
本文介绍了C#4动态关键字 - 为什么不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读了许多关于的回复后这个线程,我看到很多不喜欢的人引用滥用新关键字的可能性。我的问题是什么样的虐待?这样怎么会被严重滥用,使人们不情愿地不喜欢呢?这是纯粹主义吗?还是有一个真正的陷阱,我只是没有看到?

After reading many of the replies to this thread, I see that many of those who dislike it cite the potential for abuse of the new keyword. My question is, what sort of abuse? How could this be abused so badly as to make people vehemently dislike it? Is it just about purism? Or is there a real pitfall that I'm just not seeing?

推荐答案

有些人认为这是一个被滥用的工具。像VB中的选项严格关闭和在错误恢复下一步,像C#和Java这样的纯粹语言从未有过。

Some see it as a tool that will be abused. Like "Option Strict Off" and "On Error Resume Next" in VB which "pure" languages like C# and Java have never had.

许多人对var关键字都说了一样,但我看不到它被滥用,一旦被理解为与VB的变式

Many said the same about the "var" keyword, yet I don't see it being abused, once it became understood that it wasn't the same as VB's "Variant"

在懒惰的开发人员不希望类型检查类的地方可能会被滥用,只是尝试捕获动态调用而不是写如果blah是Blah .. 。

It could be abused in places that lazy developers don't want type checking on classes and just try catch dynamic calls instead of writing "if blah is Blah ...".

我个人觉得可以在像这个我回答的最近的问题。

I personally feel it could be used properly in situations like this recent question that I answered.

我认为真正了解它的权力是那些大量进入动态的。 NET语言。

I think the ones really understanding it's power are those heavily into the dynamic .NET languages.

这篇关于C#4动态关键字 - 为什么不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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