dynamic keyword in CSharp

Many of us like static type checking in C# because compiler can find early. But static type checking does for strict the way of write some code .You have to have type definition and metadata available at compile time in order to get work done. Before C# 4.0 it is impossible to interact with the dynamic languages such as Ruby and Python . There are also difficult in some scenarios like to work with COM objects. Anyone who trying to interop from C# code to legacy code In COM often pain . Perhaps you have felt some issues while interacting with Microsoft Office COM components to automate Word or Excel. In C# 4.0 Microsoft introduces a new keyword called dynamic. A dynamic variable is a statically typed variable is a dynamic variable. When C# compiler see the dynamically typed variable it turns off compile time check. Any operation to perform on a dynamic object reference by that variable like calling a method , setting up a property all will resolve at runtime.
dynamic person=new Person();

One thought on “dynamic keyword in CSharp

  1. Pingback: Mad Programmer | Dynamic Language Runtime in .NET(DLR)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s