A dictionary with multiple entries with the same key [duplicate]
In .NET 3.5 you can use a Lookup instead of a Dictionary. var items = new List<KeyValuePair<int, String>>(); items.Add(new KeyValuePair<int, String>(1, “first”)); items.Add(new KeyValuePair<int, String>(1, “second”)); var lookup = items.ToLookup(kvp => kvp.Key, kvp => kvp.Value); foreach (string x in lookup[1]) { Console.WriteLine(x); } The Lookup class is immutable. If you want a mutable version you … Read more