var keyword

 Updated on October 22, 2014     VIKRAM     675

var keyword

It is introduced from C# 3.0.

  • With the help of var keyword we can declare a local variable (or) method variable.
  • var type variable can not be passed as parameter to a method.
  • var type variable must be initialized during declaration itself.
  • var type variable should not be initialized with null but it can contain reference of object

 

Advantage of var type variable

  • No burden of boxing and unboxing.
  • Type safty can be achived.

 

Usage of var type variable

We can find usage of var type variable while working with LINQ.

If you enjoyed this post, please like (or) share this article.


Comments