Type Inference is one of the important features for a dynamic language; it preserves type safety while allowing you to write code with more ease. The compiler has the built-in intelligence to determine the “Type” of a variable.
There is always an argument about code readability when it comes to dynamic type inference, but when we work with external APIs and language features like LINK this becomes very handy tool, and it helps us to keep up with the design principle “Program to an Interface, not an implementation”
The keyword “var” is used to denote the complier that you are declaring a dynamic type inference variable.
var i = 0;
is equivalent to
int i = 0;
The var keyword should not be mistaken with the VB6 Variant keyword or the .netObject keyword, C# is highly type safe, when the compiler converts the code into MSIL var is replaced with the real type, to prove this try running the code mentioned below
We should name our variables meaningfully when we use the var keyword or else the readability of the code will be affected in a very bad way
we can assign constants, expression and methods with return type other than void to a variable declared with the var keyword, the var key word can be used only within a local scope, these are some valid usage