I have a Hash table that takes strings. What is the best way to dispose them ?
After using the hash table, should I call clear and then set the object to null ?
Or would just setting the hash table object to null suffice ?
I have a Hash table that takes strings. What is the best way to
Share
HashTabledoesn’t implementIDisposableso you can’t callDisposeon it, you can assign the objectnulland let the garbage collector take care of it. You can’t predict when it will be collected by the garbage collector, although you can force garbage collector withGC.Collectbut its not recommended.You may see: Fundamentals of Garbage Collection
Apart from this you may look into
Dictionary<TKey, TValue> Classwhich is generic implementation of theHashTable.