The Dictionary object stores information in name/value pairs.
Does a specified key exist?
How to create a Dictionary object, and then use the Exists method to check if a specified key exists.
Return an array of all items
How to use the Items method to return an array of all the items.
Return an array of all keys
How to use the Keys method to return an array of all the keys.
Return the value of an item
How to use the Item property to return the value of an item.
Set a key
How to use the Key property to set a key in a Dictionary object.
Return the number of key/item pairs
How to use the Count property to return the number of key/item pairs.
The Dictionary object is used to store information in name/value pairs (referred to as key and item). The Dictionary object might seem similar to Arrays, however, the Dictionary object is a more desirable solution to manipulate related data.
Comparing Dictionaries and Arrays:
The following example creates a Dictionary object, adds some key/item pairs to it, and retrieves the item value for the key gr:
The Dictionary object's properties and methods are described below:
| Property | Description |
|---|---|
| CompareMode | Sets or returns the comparison mode for comparing keys in a Dictionary object |
| Count | Returns the number of key/item pairs in a Dictionary object |
| Item | Sets or returns the value of an item in a Dictionary object |
| Key | Sets a new key value for an existing key value in a Dictionary object |
| Method | Description |
|---|---|
| Add | Adds a new key/item pair to a Dictionary object |
| Exists | Returns a Boolean value that indicates whether a specified key exists in the Dictionary object |
| Items | Returns an array of all the items in a Dictionary object |
| Keys | Returns an array of all the keys in a Dictionary object |
| Remove | Removes one specified key/item pair from the Dictionary object |
| RemoveAll | Removes all the key/item pairs in the Dictionary object |
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|