C# and .NET interview: - What is the use of "VAR" keyword in C# ?

 Posted by ArticlesMaint on 9/2/2011 | Category: .NET Framework Interview questions | Views: 7228

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 | Alert Moderator 

    Comments or Responses

    Login to post response