开发者

Should the new C# type 'dynamic' be used? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Why use dynamic typing in c#?

Should the new C# type 'dynamic' be used now much in place of Type safe variables that are compile safe? Or should it only be used in to integrate with dynamic languages like JavaScript or in areas where 'magic strings' where used to access data from XML ect.. which aren't type safe t开发者_如何学运维o begin with?


"My personal belief is that dynamic typing will be relatively rarely useful in C# 4 - basically when you're dealing with data which is already only known dynamically, e.g. reflection, or navigating XML." - Jon Skeet here
For the elaborated version: try here


I would say avoid it. Let the statically typed language remain statically typed. Unfortunately, some bloke is going to use it, and you're going to have to deal with their code. C# gave you compile time checking to use. It'd be a waste to let it go.

If you feel you want to use dynamic a lot, go write Ruby or Python. It's just the way you want to attack the problem, and there's definitely a language for that type of solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜