IHashtable.ContainsKey

Syntax

ContainsKey(Key: Variant): Boolean;

Parameters

Key. Element key.

Description

The ContainsKey method checks if there is an element with the specified key.

Example

Sub Main;
Var
    Hash: IHashtable;
    i: Integer;
    s: String;
Begin
    Hash := New Hashtable.Create;
    For i := 0 To Math.RandBetweenI(50100Do
        Hash.Add("Key_" + Math.RandBetweenI(0100).ToString, "Value " + Math.RandBetweenI(0100).ToString);
    End For;
    If Hash.ContainsKey("Key_" + Math.RandBetweenI(0, Hash.Count).ToString) Then
        s := "Yes";
    Else
        s := "No";
    End If;
End Sub Main;

After executing the example a hash table is generated, and the "s" variable is set to Yes, if it contains an element with random key.

See also:

IHashtable