I am trying to use someone else's C# classes in my Windows 7 Phone app. The classes use objects of type Hashtable.
The file in question has
using System.Collections;
at the top, so I'm assuming that's the Hashtable object it wants.
When I try to build my solution, I get errors that the type or namespace name 'Hashtable' could not be found, are you missing a using directive or assembly reference.
In Microsoft's documentation of Hashtable, I see it says Assembly: mscorlib
But if I try to add mscorlib via Project>Add Reference, VS says it can't add it because it is automatically referenced by the build system.
What am I missing?
The difference between ArrayList and HashMap is that ArrayList is an index-based data-structure supported by array, while the HashMap is a mapped data structure, which works on hashing to retrieve stored values. Although both are used to store objects, they are different in their implementation, function, and usage.
Hash tables let us implement things like phone books or dictionaries; in them, we store the association between a value (like a dictionary definition of the word "lamp") and its key (the word "lamp" itself). We can use hash tables to store, retrieve, and delete data uniquely based on their unique key.
The Hashtable class implements a hash table, which maps keys to values. Any non-null object can be used as a key or as a value. To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.
Simply put, using a hash table is faster than searching through an array. In the Find the First Non-Repeating Character algorithm challenge, we use hash tables as an optimal solution compared to nested for loops, which is a reduction in complexity from O(n*n) to O(n).
The non-generic collections, including ArrayList
and HashTable
, are not included in Silverlight.
These classes are hold-overs from .Net 1.0 (which didn't have generics) and should not be used in new code.
Instead, you should use the generic collections—List<T>
and Dictionary<TKey, TValue>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With