+ 2
How do you use var?
Please help me as all the comments I've read about using the var keyword I do not understand. So can someone please try and put it into plain English so I can understand?
2 Answers
+ 2
U may familiar with int, string, bool ,etc. At variable declaration u define the type of the variable(explicitlyâ).
when u use var u let the Compiler determine the type of the variable(implicitly). Think it as another type.
example:
var i = 10; // implicitly typed
int i = 10; //explicitly typed
"var simplifies the syntax of generic types. It is particularly useful for generic collections such as Dictionary. It allows you to omit the long type parameter lists."
0
Thanks!