About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Hash Tables

A hash table provides key/value pairing with support for efficient lookup by key. Being nongeneric, key and value are represented as System.Object. An exploratory example is shown here:

var tbl = new Hashtable();tbl.Add("Bart", 29);tbl["John"] = 64;bool bartIsKnown = tbl.ContainsKey("Bart");bool someIsAged64 = tbl.ContainsValue(64);foreach (string name in tbl.Keys)    Console.WriteLine("Age of {0} is {1}", name, tbl[name]);tbl.Remove("Bart");

Internally, keys are hashed by making a virtual method call to the key’s GetHashCode implementation. The idea of a hash code is to provide an integer value for an object with as good uniqueness properties as possible. Whenever an entry is requested from the table ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required