What Is The Difference Between Var And Dynamic Types In C# 4.0?

user image

Muskan Anand

2 years ago

var gets processed in the compile time itself and shows any error during compile time itself. dynamic gets processed in the runtime only and in case of errors it is hidden until runtime. dynamic was introduced as part of the DLR (Dynamic Language Runtime)in .Net. Example: dynamic d = new MyClass(); d.InexistingMethod(); Eventhough the method "InexistingMethod" is not there - it will get compiled and thrown exception in runtime.

Recent Doubts

Close [x]