0
What is that mean var and when we use it
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.
- 2
its more like an automatic or universal variable type that can occupy any data type. e.g string or int