tags:

views:

111

answers:

3

how to add duplicate keys to dictionary

i.e i have already added the key,value pair as rollno,1 but i need to add the same parameter to the dictionary,but it is not allowing to add. how to add duplicated keys/repeated key in dictionary .

or any other choice.. any idea???

+2  A: 

Hi there.

Check out this:

http://stackoverflow.com/questions/1403493/what-is-the-point-of-lookuptkey-telement

You can use the Lookup class to help you create collections with duplicates keys.

Cheers. Jas.

Jason Evans
A: 

You cannot add duplicate keys to a dictionary. Keys in a dictionary are intended to be unique.

chibacity
+3  A: 

That doesn't make sense, if you added duplicate keys to the dictionary, how would it be able to find which one you want when you look them up?

Possibly you're looking for something like a `List< KeyValuePair < T, T > >'? Where you could store a list of pairs rather than an actual dictionary.

ho1