Apr 26

Type inference in C# 3.0

Posted in C# Trivia      Comments Off on Type inference in C# 3.0

My friend Paulo published a post that talks about type inference and how it might evolve in the next years. Even though type inference”s main objective is to support LINQ (in fact, most of the new stuff that C#3.0 introduced is only there to support LINQ), I must say that I”ve been enjoying it a lot and I”ve been using it whenever possible. Initially, I wasn”t really into using var because I thought that it would reduce the readability of my code and I”ve only started using it after installing one of the nightly builds of R#. In fact, I was one of the first to complain on the R# forums about it.

Anyway, I decided to give it a try and guess what? I”ve noticed that using this approach will not reduce my code readability. In fact, I”ve noticed an improvement on my local variables” names. I know that this might look really strange at first, but believe me: give it a try and I bet you”ll end up loving it (and let me tell you that this is helping my with my carpal tunnel syndrome :),,)