Possible Duplicate:
Is there an alternative to Dictionary/SortedList that allows duplicates?
I am looking for a Dictionary sort of class which can have duplicate Keys.
I search about it, and found LookUp class can use to store duplicate keys, but It has no default constructor, So we can’t initialize it without any other object to LookUp.
But I have no any such object initially from which I can initialize a LookUp object.
So, My question is, Is there any class in .Net framework 3.5, which behave like Dictionary but allow me to have duplicate keys like LookUp?
A Dictionary, by definition, will never be able to have multiple keys with the same value. (If you looked up a key whatever would you return?) Even a Lookup, which you refer to, doesn’t allow it. What you can do is have each key refer to multiple values (logically, not technically). This is done by having a dictionary in which the value is a data structure of some sort (for example, a
List) that contains all of the values that correspond to that particular key.