Thursday, October 16, 2008

Dictionary: surprising fact about Remove and Clear methods

Both these methods never resize internal bucket list of the Dictionary - this means dictionary bucket list may only grow up during its lifetime, and the only way to "shrink" it is to recreate the dictionary (create a new one, copy the content of the old one to it and forget the old one).

To get the approval of this fact, study the source code of both methods - e.g. with .NET Reflector.