Possible Duplicate:
C# Sortable collection which allows duplicate keys
Basically I'd like to make a Dictionary work with duplicate keys without going into custom comparer implementations. There is an idea of:
Dictionary<key, List<value>>
but it still has some overhead. I wish Dictionary had "AllowDuplicates".
In SortedDictionary, the key must be unique. Duplicate keys are not allowed. In SortedDictionary, the keys are immutable and cannot be null. In SortedDictionary, the value can be null when the type of the value is of reference type.
In Dictionary, key must be unique. Duplicate keys are not allowed if you try to use duplicate key then compiler will throw an exception. In Dictionary, you can only store same types of elements. The capacity of a Dictionary is the number of elements that Dictionary can hold.
You can use List<KeyValuePair<string,int>> . This will store a list of KeyValuePair 's that can be duplicate.
If you're using .NET 3.5 then Lookup is probably what you're after.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With