Reputation: 61463
I'm studying the .NET Hashtable class, and would like to experiment with various aspects...
How can I experiment or learn the above information regarding a given hashtable or dictionary
Upvotes: 3
Views: 787
Reputation: 72860
The thread safety of Hashtable
is stated in MSDN. It is thread safe if only one thread writes to the Hashtable
, and this has to include expansion.
Now, some digging using Reflector:
The load factor is stored in the loadFactor
private field, which you can access using reflection if you want to check its value.
Rehashes are harder. These is no internal state of the Hashtable
that is modified in a detectable way by a rehash and only by a rehash. Thus you would have to look at other options here, for example using Reflector to create your own identical Hashtable implementation and then adding some code to count rehashes. If you're doing that, you may as well expose the load factor as a property as well to make your life easier.
Upvotes: 2