Differences between var and dynamic in C# | Var vs Daynamic | C# Bangla Tutorial | Advanced C#


Differences between var and dynamic in C#

Var


1. It is introduced in C# 3.0
2. The variables are declared using var keyword are statically typed.
3. The type of the variable is decided by the compiler at compile time.
4. The variable of this type should be initialized at the time of declaration.
5. If the variable does not initialized it throw an error.
6. It support intelliSense in visual studio.
7. It cannot be used for parameter and returning values from the function.

Dynamic

1. It is introduced in C# 4.0
2. The variables are declared using dynamic keyword are dynamically typed.
3. The type of the variable is decided by the compiler at run time.
4. The variable of this type need not be initialized at the time of declaration.
5.If the variable does not initialized it will not throw an error.
6. It does not support intelliSense in visual studio.
7. It can be used for parameter  returning values from the function.

Post a Comment

Previous Post Next Post