IDictionary.Add

Syntax

Add(Key: Variant; Value: Variant);

Parameters

Key. Dictionary element key.

Value. Dictionary element value.

Description

The Add method adds an element to glossary.

Example

Sub UserProc;
Var
    Hash: IHashtable;
    i: Integer;
    s: String;
    c: Char;
Begin
    Hash := New Hashtable.Create;
    //Generate random hash table
    For i := 0 To 10 Do
        Hash.Add("Key_" + Math.RandBetweenI(0100).ToString, Char.Chr(Math.RandBetweenI(6590)));
    End For;
    //View generated keys
    For Each s In Hash.Keys Do
        Debug.WriteLine(s);
    End For;
    //View generated values
    For Each c In Hash.Values Do
        Debug.WriteLine(c As String);
    End For;
End Sub UserProc;

After executing the example a hash table is created that contains elements with random keys and values. The list of keys and values is displayed in the development environment console.

See also:

IDictionary