0

Possible Duplicates:
C# ‘var’ keyword versus explicitly defined variables
Use of var keyword in C#

May I know where to use 'var' keyword and the purpose of using that there ?

Community
  • 1
  • 1
SRA
  • 1,681
  • 7
  • 27
  • 49

2 Answers2

0

Sure, just check one of the many links here : https://stackoverflow.com/search?q=c%23+var+keytword ;)

Community
  • 1
  • 1
Iain Ward
  • 9,850
  • 5
  • 34
  • 41
0

You can use the var keyword to infer the type of an object.

For example:

//without using the "var" keyword
Dictionary<List<string>,int> myCustomDictionary = new Dictionary<List<string>, int>();

//with the "var" keyword
var myCustomDictionary = new Dictionary<List<string>, int>();

Which is easier to read? :)

Doctor Jones
  • 21,196
  • 13
  • 77
  • 99