Monday, August 10, 2015

The C# dynamic Keyword in C# 4.0 and upwards

dynamic keyword a specialized form of System.Object, in that any value can be assigned to a  dynamic data type.
• a data point declared with the dynamic keyword can be assigned any initial value at all, and can be reassigned to any new (and possibly unrelated) value during its lifetime.
• IntelliSense is not possible with dynamic data.
• It is not mandatorily to use dynamic keyword  (With Dynamic keyword, The intention is to reduce verbose, that’s it)
• It is not statically typed it means that validity of dynamic statement is checked at runtime not at compile time
• Invalid dynamic statement is validated at run time using RuntimeBinderException  available in Microsoft.CSharp.dll
• Cannot make use of lambda /anonymous methods
• Cannot understand any extension method
• It is used in cases where your .Net application interacts with COM libraries (like Microsoft Office products) or VSTO application
• Can be used as parameters, return value or a member of class/structure


No comments:

Post a Comment