Type inference, don’t get bitten by var

I've been playing with some of the new features in C#, one of which being the var keyword.  Which is not dynamic typing, it is just type inference.  Meaning that the compiler will be assigning the type based on the value that you initialise the variable with when declaring it.  And you have to initialise it with an actual value when using var.

After playing a bit, I discovered this little problem, which is probably just an incorrect assumption from my side, but I'm sure I'm not the only one that will make this assumption.  If you look at this code sample.

Continue reading Type inference, don’t get bitten by var