Introduction to Dictionary objects in ASP and how to use them
The Dictionary object is used to store information (equivalent to keys and items) in the name/value of a pair. Dictionary objects seem simpler than arrays, but
, the Dictionary object is a more satisfying solution for dealing with associated data.
First, let's look at the Comparative analysis of Dictionary and array:
Keys are used to identify items in the Dictionary object
You do not need to invoke ReDim to change the size of the Dictionary object
When you delete an item from Dictionary, the remaining items are automatically moved up
Dictionary is not multidimensional, and arrays are
Dictionary has more built-in objects than arrays
Dictionary works better than arrays when it accesses random elements frequently
Dictionary work better than arrays when locating items based on their content
Introduction to the properties and methods of Dictionary objects in asp:
Dictionary Property
CompareMode: Sets or returns the comparison mode used to compare keys in the Dictionary object.
Count: Returns the number of key/item pairs in the Dictionary object.
Item: Sets or returns the value of an item in the Dictionary object.
Key: Sets a new key value for the key value already in the Dictionary object.
Method
Add: Adds a new key/project pair to the Dictionary object.
Exists: Returns a logical value that indicates whether the specified key exists in the Dictionary object.
Items: Returns an array of all items in the Dictionary object.
Keys: Returns an array of all the keys in the Dictionary object.
Remove: Deletes the specified key/item pair from the Dictionary object.
RemoveAll: Deletes all key/item pairs in the Dictionary object.