VAR is a implicit way of defining variable in .NET.Implicit means indirect way of defining variable types.
VAR is used primarily in 2 kinds of scenarios: -
When you have long class names and your code is not readable so by using VAR keyword the code becomes short and sweet.
When you are using LINQ and anonymous types VAR keyword reduces your code for creating special classes.
Also view the following video on use of "VAR" keyword in .NET and C#: -
Asked In: Many Interviews |