LANGUAGE

var local type inference

Infers the static type of an ordinary local variable from its initializer. The initializer must provide an inferable type; var does not make the variable dynamically typed.

Formal Syntax & Structure

csharp syntaxcsharp
var <identifier> = <expression>;

Working Example

Example Snippetcsharp
var count = 5;count = 8;System.Console.WriteLine(count);
C# & .NET Reference