Below are some important points about
var keyword introduced in C# 3.0 onwards
1.
var type of variables can't be assigned null.
2.
var variables must be initialized at the time of declaration, however after declaration it can be assigned as null.
3. The initializaton method of of
var variable can return null.
4.
var variables can be defined for any C# data types variables and any custom types variables for example a class.
5. The
var keyword is understood by the Visual Studio compiler only. The compiled assembly contains the normal .NET 2.0 assembly.
6. The
var variable is widely used in writing LINQ queries, however it can be used in normal programming as well and now at many occassions it is suggested to use var keyword to declare any types of variables.
var v = 5; // correct
var vv = null // incorrect
string s = null;
var vvv = s // correct
Hope this helps