This article we will discuss what is the difference between var and Dynamic in c sharp 4.0
Var
|
Dynamic
|
1-
It is a keyword that is used for implicit variable declaration at compile
time.
|
1
It is a keyword used for variable declaration at runtime.
|
2-
errors caught at compile times
|
2-
Errors caught at runtimes.
|
3-
Var cannot be used as the return type of methods and can’t used to declare
variables at class level.
|
3-
Dynamic can also be used as return type of the methods.
|
4-It is type safe i.e. Compiler has all information about the stored
value, so that it doesn't cause any issue at run-time.
|
4-It
is not type safe i.e. Compiler doesn't have any information about the type of
variable.
|
No comments:
Post a Comment