Tuesday 15 May 2012

Linq makes creating dictionaries easy

Previously, I wrote example code that used one of my library functions to construct a dictionary when given a list or pair of list. Since the place of gainful employment moved to .NET 3.5 I have been able to write some truly linq-y code, and have observed many wonderful things, in particular the extension methods of IEnumerable. Check out ToDictionary( keyFn, valueFn) It's exactly what I was writing in my Functional.array.toDict function. Good work, Microsoft!