Duplicate keys in .NET dictionaries?

If you’re using .NET 3.5, use the Lookup class.

EDIT: You generally create a Lookup using Enumerable.ToLookup. This does assume that you don’t need to change it afterwards – but I typically find that’s good enough.

If that doesn’t work for you, I don’t think there’s anything in the framework which will help – and using the dictionary is as good as it gets 🙁

Leave a Comment