Differance between var and dynamic in c#
The below differance are very usefull and cachhe words..... var dynamic Introduced in C# 3.0 Introduced in C# 4.0 Statically typed – This means the type of variable declared is decided by the compiler at compile time. Dynamically typed - This means the type of variable declared is decided by the compiler at runtime time. Need to initialize at the time of declaration. e.g., var str=”I am a string”; Looking at the value assigned to the variable str , the compiler will treat the variable str as string. No need to initialize at the time of declaration. e.g., dynamic str; str=”I am a string”; //Works fine and compiles str=2; //Works fine and compiles Errors are caught at compile time. Since the compiler knows about the type and the methods and properties of the type at the compile time itself Errors are caught at runtime Since the compiler comes to about the type and the methods and properties ...