Hashtable, retrieve first entry in case of duplicate key

  • Thread starter Thread starter christophe.leroquais
  • Start date Start date
C

christophe.leroquais

Hi,

I have a HashTable that can have the same keys.
For example:

Key: myKey1, myKey2, myKey3, myKey1
Value: "value1" , "value2" , "value3", "value4"

That's ok and I'm happy with that.
My issue is that when I want to retrieve the entries one by one, I want
it to retrieve only the first entry in case of duplicate on the Key.

Is that possible to do that?

Thanks,

Christophe
 
Not without coding this logic yourself


But in my opinion using a hashtable in this situation doesn`t make sense ,
you could also use a 2 dimensional object array
this is more lowlevel and just as easy to code the required behavior around
it

A hashtable should be used for key value pairs the definition of a key is
that it should be unique


regards

Michel
 
Hi,

I have a HashTable that can have the same keys.
For example:

Key: myKey1, myKey2, myKey3, myKey1
Value: "value1" , "value2" , "value3", "value4"

That's ok and I'm happy with that.
My issue is that when I want to retrieve the entries one by one, I want
it to retrieve only the first entry in case of duplicate on the Key.

Is that possible to do that?

Thanks,

Christophe

To add to what Michael said - the fact is that you can't even do what your
trying to do. The hashtable will not allow duplicate keys. It will throw an
exception if try....
 
Back
Top