var

The C# keyword that asks the compiler to infer a local variable's type from its initial value and then fix it there.

In more detail

var is not dynamic typing: var sku = "wid-7"; makes sku a string forever, and assigning a number later will not compile. Use it when the type is obvious from the right-hand side.

Example

var sku = "wid-7"; // sku is a string

Related terms

Taught in

References