What\'s the best way to merge 2 or more dictionaries (Dictionary) in C#? (3.0 features like LINQ are fine).
Dictionary
I\'m thinking of a method signa
or :
public static IDictionary Merge( IDictionary x, IDictionary y) { return x .Except(x.Join(y, z => z.Key, z => z.Key, (a, b) => a)) .Concat(y) .ToDictionary(z => z.Key, z => z.Value); }
the result is a union where for duplicate entries "y" wins.