C# 3.5 Starting to Gel

by Jason Haley 10. February 2009 13:34

Ok, so I know I’m not on the bleeding edge … if you are – then you can stop reading this entry now.

Since I find myself a little behind on some of the new stuff, I’ve been focusing on the new C# features the last month or so (in spare time – which always seems to be less than I would like).  If you read my blog, then you know I read Jon Skeet’s book (Book Review- C# in Depth) and lately I’ve been reading Bill Wagner’s book: More Effective C#: 50 Specific Ways to Improve Your C# (Effective Software Development Series).  I’m now into the LINQ chapter …

After reading about (but not heavily using) LINQ and seeing samples like:

   1: int[] numbers = { 0,1,2,3,4,5,6,7,8,9 };
   2: var smallNumbers = from n in numbers
   3:              where n < 5
   4:              select new { Number=n, Square=n*n};

On one level I understand what is going on, even with the funky syntax … but only to the point that if I don’t use it I’ll soon forget it. 

Today at lunch it all started to gel while watching the PDC video An Introduction To Microsoft F# 

After watching Luca Bolognese explain how a somewhat real world example of F# works, step-by-step, … for some reason – the following code now makes perfect sense:

   1: int[] numbers = { 0,1,2,3,4,5,6,7,8,9 };
   2: var sNumbers = numbers.Where(n=> n < 5).Select(n => new { Number=n, Square=n*n});
Which is all the earlier example is but with a little compiler pixie dust added …

Comments (0) | Post RSSRSS comment feed |

Categories:
Tags:

Comments are closed