var
Implicitly typed local variable. The compiler infers the type from the initializer. The type is still static and fixed at compile time.
Syntax
csharp
var variableName = value;Example
csharp
var count = 42; // int
var name = "Alice"; // string
var items = new List<int>(); // List<int>
var dict = new Dictionary<string, int>();
// Useful for complex types:
var query = from u in users where u.Active select u;