February 2010 Entries

Enumerable::ToList() - C++ Missing From MSDN

It seems the C++ code example for Enumerable::ToList() is absent/missing from MSDN. Here is my version of the missing example for Enumerable::ToList();

Linq Distinct and Custom Object Sort

I've seen a lot of posts of people having problems using Distinct() and/or Sort() with custom objects. Here is an example showing an implementation of both (in C++, C# and VB). This post includes custom Compare methods, the implementation of Distinct() and the use of List.ForEach in the 3 main dot net languages.

ILookup

There are many times where I need to convert an array of data into a Dictionary or Hash table. If the key to be used in the new Dictionary is not unique, it is necessary to manage duplicates. I previously went through a lot of gyrations, but eventually setteled on the ILookup. ILookup is not perfect, but it beats some alternatives.