+ 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?

21st Apr 2017, 2:48 PM
Zak Polley
Zak Polley - avatar
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."
21st Apr 2017, 2:58 PM
Eranga
Eranga - avatar
0
Thanks!
23rd Apr 2017, 12:49 PM
Zak Polley
Zak Polley - avatar