Use of var keyword in C#

The var keyword in C# was introduced from C# 3.0 and it beings in the feature of local type inference or implicit type variable in C#.

LINQ is one of the case where var keyword can be widely used in C#.

Eg:

var name = "Abundant Code";

In the above example, the initialization of the name was done using “string” and hence name will be implicitly treated as string.

Note that the implicit type variables cannot be initialized to null and cannot be treated or used as a member of the class.

%d