• home
  • Email: trainings@synapseindia.careers



Understanding the Dynamic Keyword in C# 4

May 02, 2015

Programming languages are sometimes divided into statically typed and dynamically typed languages. C# and Java are  often considered examples of statically typed languages, while Python, Ruby and JavaScript are examples of  dynamically typed languages. Generally speaking, dynamic languages don’t perform compile-time type checks and identify the type of objects at  run time only. This approach has its pros and cons: Often the code is much faster and easier to write, but at the  same time you don’t get compiler errors and have to use unit testing and other techniques to ensure the correct behavior of your application. Originally, C# was created as a purely static language, but with C# 4, dynamic elements have been added to improve  interoperability with dynamic languages and frameworks. The C# team considered several design options, but finally  settled on adding a new keyword to support these features: dynamic. The dynamic keyword and the Dynamic Language Runtime (DLR) are major new features in C# 4 and the Microsoft .NET  Framework 4.The dynamic keyword acts as a static type declaration in the C# type system. This way C# got the  dynamic features and at the same time remained a statically typed language. When you use the dynamic keyword you  tell the compiler to turn off compile-time checking.Absence of compile-time type checking leads to the absence of  IntelliSense as well. Because the C# compiler doesn't know the type of the object, it can’t enumerate its  properties and methods.

SynapseIndia (CEO: Shamit Khemka)

Leave a Reply

Your email address will not be published.