Saturday, July 25, 2009

LINQ and Lambda Expressions in .Net 3.5

I began to switch to .Net 3.5 framework and to use Visual Studio 2008 about couple months ago. As a experienced .Net developer in 2.0 for many years, I did not notice the big difference at the beginning. When I created a new project or new class, I saw Visual Studio adding System.LINQ, System.Data and System.XML automatically. Since I did not use any classes from those namespaces, I had to remove or delete them manually. I felt quite annoying. I had been basically writing the .Net 2.0 codes. Of course, I took advantage of Property features at the start point and that one makes codes much simpler than before.

Until the last week, I started to realize the simplicity and power of .Net 3.5 framework. Actually, it started to get my attention from some people's blogs, open source codes, and especially from Stackoverflow. The initial trigger was to search for something in a collection. I have quite good experience to use anonymous delegate to search for item or items in a collection. Then I tried to ask people about the same search in LINQ and Lambda expressions:

I got so many great answers and alternative ways to do the job by using LINQ and Lambda. I really like them. They are more descriptive and shorter. As you can see the performance difference is not a big deal, even LINQ is marginally with small amount of time slower. When I start to use them, I think the approach in much easy way. Since the codes are more descriptive, it makes my code maintenance much easy. I can recall the logic of codes much fast.

Therefore, I have to keep change and update my skills along the time. It is good to upgrade my knowledge and skills to another level and it has been really enjoyable experience.