473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hashtable, retrieve first entry in case of duplicate key

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

Jan 5 '07 #1
2 1982
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

<ch******************@gmail.comschreef in bericht
news:11*********************@i15g2000cwa.googlegro ups.com...
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

Jan 5 '07 #2
On 2007-01-05, ch******************@gmail.com <ch******************@gmail.comwrote:
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....

--
Tom Shelton
Jan 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13805
by: shine | last post by:
I am trying to add an integer array to a hashtable. While adding to hashtable I want to check the duplicates in array, the way I want to do is add the key(the integer stored in array) if a...
2
2194
by: William Stacey [MVP] | last post by:
I am doing a dns zone type of project which has an inverted tree like you all know. test.com. (top node. value contains arraylist of all test.com records) www.test.com. (node. value contains...
1
8697
by: francois | last post by:
Hi, I have a webservice that I am using and I would like it to return an XML serialized version of an object. the class of the object is defined serializable as the following: public...
5
2812
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
33
3285
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
3
1530
by: Rich | last post by:
Hello, I populate a hashtable with recordID's in a "For i=0 to n" loop. Some recordID's are duplicate but for different rows (recordID is not a key field in this scenario). I use the value of...
2
3137
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
12
3339
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I'm creating a hashtable of a list of users in AD. The keys are UserID and Password. I want to loop through the table to compare the userID and password with values that a user has...
7
2663
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.