Hi All,
I use a Hashtable in my program to keep unique items...at one instance I
need to repopulate this hashtable through a loop.
when starting repopulation hashtable.count() returns ZERO hence first item
gets added successfully but as soon as the control reaches top of foreach
loop
somehow a second item which indeed existed before repoulation started
appears in hashtable and count returns two hence this second item can not
add itself because of duplicate key.
I tried allocating a new object to hashtable as well as clear() before
repopulating but same weird behaviour.
At the end I have to check in repopulation code that if key existed then
dont add it ...my code worked for time
but just wondering....why why why?
Any thoughts ?
-TIA
Pankaj
Jon Skeet [C# MVP] - 13 May 2004 21:00 GMT
> I use a Hashtable in my program to keep unique items...at one instance I
> need to repopulate this hashtable through a loop.
[quoted text clipped - 3 lines]
> appears in hashtable and count returns two hence this second item can not
> add itself because of duplicate key.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too