C Sharp Programming/Keywords/var

The keyword can be used in place of a type when declaring a variable to allow the compiler to infer the type of the variable. This feature can be used to shorten variable declarations, especially when instantiating generic types, and is even necessary with LINQ expressions (since queries may generate very complex types).

The following:

is equivalent to:

does not create a "variant" type; the type is simply inferred by the compiler. In situations where the type cannot be inferred, the compiler generates an error:

/Keywords Note: Var is not a keyword