Per the Hashtable Class docs:

"The objects used as keys in a Hashtable must implement or inherit the
Object.GetHashCode and Object.Equals methods. If key equality were simply
reference equality, the inherited implementation of these methods would
suffice. Furthermore, these methods must produce the same results when
called with the same parameters while the key exists in the Hashtable. Key
objects must be immutable as long as they are used as keys in the
Hashtable."

Assuming you have the ability to modify the Item code, override the default
implementation of GetHashCode and Equals to provide/use a unique key.  If
Item isn't changable or providing a default implementation of Equals would
break too much, you could consider a wrapper class for the Item objects.
The wrapper class would be stored in the Hashtable instead.

On Fri, 12 Sep 2003 13:25:27 +0400, Dmitry Shaporenkov wrote:

>Hi all,

<Snip>

>However, I need a way to identify items in a thread-independent fashion.
>Items themselves do not have any properties which might serve as a reliable
>unique identifiers.

<Snip>

>Any advices / references will be greatly appreciated. Thanks in advance.
>
>Regards,
>Dmitry Shaporenkov

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to