Implicitly Typed Variables in .net 3.5

We can now declare a variable and allow the compiler to determine the type of the item implicitly. We will find that LINQ(Language Integrated Query ) uses this capability to work with the queries that are created. To work with this new capability, you use the var keyword:

 

var x = 5;

 

When we use above statement, the compiler will actually use the value of 5 to figure out the type that this needs to be. That means, in this case, that the statement will actually be as we would expect:

 

int x = 5;

Ebook Download
View all
Learn
View all