I have been recently studying more on the dynamic types in C#. With some examples I understood once the code is compiled, it does not need to be recompiled again but can be executed directly.
I feel the flexibility provided by the keyword to actually be able to change data type at will is a great advantage.
Question,
Are there any specific shortcomings apart from wrong dynamic method calls which throw run time exceptions which developers must know before starting the implementation.
object
or direct type casts to be a code-smell. In almost every case it meant that I or one of my team hadn't designed an appropriate interface for that functionality. I'm guessing that if I were using C# 4 now, I would feel pretty much the same way about use ofdynamic
too. I could see the case for it if you make everything dynamic, but in that case you might as well have selected a dynamic typed language in the first place. *8')dynamic
in C# means you don't have to drop out to IronPython if all you need is some dynamic typing for a small part of your code. For an expression evaluator, I've had great success usingdynamic
to represent the operands of an expression and the results from evaluation.dynamic
, plus I wish I'd known about IronPython when I was developing with .Net - it could have made certain things we were trying to do much easier.