Dictionary Data Type

Modified on 2010/02/24 21:56 by Administrator — Categorized as: Uncategorized

Represents a collection of key/value pairs that are ordered based on the key/index. The key is a case-insensitive String.


Constructors

Dictionary ( )

Initializes a new empty Dictionary instance.

Syntax:

Dictionary()

Example:


dict = new Dictionary();

Instance Properties

Count

Gets the number of items in the dictionary.

Accessibility : Read Only

Type: Number

Instance Methods


Examples


d = new Dictionary();
d.Add("Apple", 0.59);
d.Add("Orange", 0.41);
d.Add("Pear", 0.62);

// Check for existance of key
if ( d.Contains("Pear") )
{
  // do something
}

// Enumerate contents
totalPrice = 0;
for ( i = 0; i < d.Count; i++ )
  totalPrice = totalPrice + d(i);