0

What is that mean var and when we use it

16th Aug 2016, 1:03 PM
Rami Salim
Rami Salim - avatar
2 Answers
+ 4
When you declare a variable, you have to specify the datatype. int x; But when you don't know what datatype will be stored in that variable, use the keyword var instead. var x; Then, if you assign an integer to x it's datatype will be int, if you assign an string value to it, the datatype for x will be set to string and so on. var can be described as the dynamic datatype.
16th Aug 2016, 2:34 PM
Alireza M
Alireza M - avatar
- 2
its more like an automatic or universal variable type that can occupy any data type. e.g string or int
17th Aug 2016, 12:17 PM
Joshua Ng andwe
Joshua Ng andwe - avatar