For ex: I am having class name data and am going to create instance for this
var abc =new data()
And data abc =new data()
here why we can go for var?
For ex: I am having class name data and am going to create instance for this
var abc =new data()
And data abc =new data()
here why we can go for var?
Var keyword is an implicit way of defining Data Types. Implicit means indirect way of defining variable types. In simple words by looking the data at the right hands side the left hands side data types is defined by the compiler during the generation of the “IL” code. In the case of class instance, var provides two important uses, such as,
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.
Please click on this link and scroll to the middle of the page, you can find why to use var in case of class instance.