December 2001
Intermediate to advanced
416 pages
8h 16m
English
The System.Collections namespace provides a Hashtable container. A Hashtable represents a key/value pair in which the key is used for fast lookup. In other languages, we might call our table map or Dictionary. We'll use the Hashtable object to hold the occurrence count of the individual words.
We'll use the word as the key. The occurrence count is the value. If the word is not yet entered in the table, we add the pair, setting the occurrence count to 1. Otherwise, we use the key to retrieve and increment the occurrence count. Here is what this looks like:
Hashtable words = new Hashtable(); int dim1_length = sentences.GetLength( 0 ); for( int ix = 0; ix < dim1_length; ++ix ) { foreach ( string st in sentences[ ix ...Read now
Unlock full access