Its a implicit or indirect way of defining data types i.e by looking the data at RHS the LHS data type are define by the compiler during the generation of the IL Code. In IL code actual data type will be present as per data.
Var keyword define data type statically and not on runtime i.e value type can not be change at runtime.
When to use VAR ?
- In Linq query where we are not sure what kind of columns query will return i.e Anonymous Type. If we will not use var then we have to create a POCO class to store the Linq query result which will be a overhead.
- Rarely but when class name are big enough to write
var i= 10; i = "Jogendra"; //Here it will give the COMPILE time error which proves that var keyword data type set statically