System.Collections.Specialized.ListDictionary.Add Method

Adds an entry with the specified key and value into the System.Collections.Specialized.ListDictionary.

Syntax

public void Add (object key, object value)

Parameters

key
The key of the entry to add.
value
The value of the entry to add. The value can be null.

Remarks

An object that has no correlation between its state and its hash code value should typically not be used as the key. For example, String objects are better than StringBuilder objects for use as keys.

You can also use the ListDictionary.Item(object) property to add new elements by setting the value of a key that does not exist in the System.Collections.Specialized.ListDictionary; for example, myCollection["myNonexistentKey"] = myValue. However, if the specified key already exists in the System.Collections.Specialized.ListDictionary, setting the ListDictionary.Item(object) property overwrites the old value. In contrast, the ListDictionary.Add(object, object) method does not modify existing elements.

This method is an O(n) operation, where n is ListDictionary.Count.

Requirements

Namespace: System.Collections.Specialized
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0