Good implementation of weak dictionary in .Net

Konstantin Spirin picture Konstantin Spirin · May 6, 2010 · Viewed 14.9k times · Source

Where can I find good implementation of IDictionary which uses weak references inside?

Dictionary should be holding only weak references to values and eventually clean up itself of dead references.

Or should I just write it myself?

Answer

madrang picture madrang · Oct 17, 2012

ConditionalWeakTable Class uses weak keys and automatically removes the key/value entry as soon as no other references to a key exist outside the table.