-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: sruno127
Message 9 in Discussion
hi balaji, Hope this is helpful to you HashTable Hash tables use key and value
pairs. The key is processed through a hashing function that is designed to generate a
unique value that is then used as an index into the hash table to the location
containing the value. Hash tables strike a balance between resource usage and speed.
Instead of probing each element for equality to determine whether objects are
equal, simply processing the key provides an index to the location that contains the
associated value. The System.Collections.HashTable class implements a hash table
available for you to use. HashTable works externally much like a data dictionary.
Provide a unique key and an associated value, and the HashTable takes care of the
rest. Suppose you were storing personnel records in memory for quick access.
You might key each record on the Social Security number, and the value would be the
personnel record. (For Example, we will simply store a person's name to represent the
personnel record.) Declares a new instance of a hash table and adds some unique
elements to the hash table keyed on pseudo-Social Security numbers. The values stored
in the hash table represent the data associated with the keys. (The key is the first
argument and the value is the second argument of the Add method.) Storing items
in a hash table.
Sub DemoHashTable()
Dim Hash As New Hashtable()
Hash.Add("555-55-5555", "Frank Arndt")
Hash.Add("555-55-5556", "Mary Bonnici")
Hash.Add("555-55-5557", "Paul Kimmel")
Dim Enumerator As IDictionaryEnumerator = Hash.GetEnumerator //declares an
enumerator
//iterate over each element displaying the key and value pairs. While
(Enumerator.MoveNext())
Debug.WriteLine(Enumerator.Key & "=" & Enumerator.Value)
End While
End Sub Enumerator objects are read-only. To modify elements of a collection
like a HashTable, you can use a For Next loop, indexing the elements of the collection
directly. HashTable uses an IDictionaryEnumerator object to iterate over
elements.(.Key and .Value were not defined in the IEnumerator interface; they were
added in the IDictionaryEnumerator.) We must call MoveNext to advance the enumerator
to the first element of the collection before reading the value of Current. bye sruno
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]