Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong><code>Dictionary</code></strong> &lt;&lt;&lt;>>> <strong><code>Hashtable</code></strong> differences:</p> <ul> <li><strong>Generic</strong> &lt;&lt;&lt;>>> <strong>Non-Generic</strong></li> <li>Needs <strong>own thread synchronization</strong> &lt;&lt;&lt;>>> Offers <strong>thread safe</strong> version through <strong><code>Synchronized()</code></strong> method</li> <li>Enumerated item: <strong><code>KeyValuePair</code></strong> &lt;&lt;&lt;>>> Enumerated item: <strong><code>DictionaryEntry</code></strong></li> <li>Newer (> <strong>.NET 2.0</strong>) &lt;&lt;&lt;>>> Older (since <strong>.NET 1.0</strong>)</li> <li>is in <strong>System.Collections.Generic</strong> &lt;&lt;&lt;>>> is in <strong>System.Collections</strong> </li> <li>Request to non-existing key <strong>throws exception</strong> &lt;&lt;&lt;>>> Request to non-existing key <strong>returns null</strong></li> <li>potentially a bit <strong>faster for value types</strong> &lt;&lt;&lt;>>> <strong>bit slower</strong> (needs boxing/unboxing) for value types</li> </ul> <p><strong><code>Dictionary</code></strong> / <strong><code>Hashtable</code></strong> similarities:</p> <ul> <li>Both are internally <strong>hashtables</strong> == fast access to many-item data according to key</li> <li>Both need <strong>immutable and unique keys</strong></li> <li>Keys of both need own <strong><code>GetHashCode()</code></strong> method</li> </ul> <p><strong>Similar</strong> .NET collections (candidates to use instead of Dictionary and Hashtable):</p> <ul> <li><code>ConcurrentDictionary</code> - <strong>thread safe</strong> (can be safely accessed from several threads concurrently)</li> <li><code>HybridDictionary</code> - <strong>optimized performance</strong> (for few items and also for many items)</li> <li><code>OrderedDictionary</code> - values can be <strong>accessed via int index</strong> (by order in which items were added)</li> <li><code>SortedDictionary</code> - items <strong>automatically sorted</strong></li> <li><code>StringDictionary</code> - strongly typed and <strong>optimized for strings</strong></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload