Enumerable.ToDictionary(TSource, TKey) Method (IEnumerable(TSource), Func(TSource, TKey)) (System.Linq):

class Package
public string Company { get; set; }
public double Weight { get; set; }
public long TrackingNumber { get; set; }


// Create a Dictionary of Package objects,
// using TrackingNumber as the key.
Dictionary dictionary =
packages.ToDictionary(p => p.TrackingNumber);

Oh, good heavens. Really? Lambda expressions? Obfuscationing weirds language.

(In retrospect, that last sentence would potentially make for a better blog name.)

Labels: ,