Add(Key: Variant; Value: Variant);
Key. Dictionary element key.
Value. Dictionary element value.
The Add method adds an element to glossary.
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(0, 100).ToString, Char.Chr(Math.RandBetweenI(65, 90)));
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: