IStringMap.ContainsKey

Syntax

ContainsKey(Key: String): Boolean;

Parameters

Key - key of the element, which existence should be checked.

Description

The ContainsKey method checks if the element with the Key key exists.

Example

Sub Main;

Var

StrMap: IStringMap;

i: Integer;

s: String;

Begin

StrMap:=New StringMap.Create;

For i:=0 To Math.RandBetweenI(50,100) Do

StrMap.Add("Key_"+Math.RandBetweenI(0,100).ToString ,"Value "+Math.RandBetweenI(0,100).ToString);

End For;

If StrMap.ContainsKey("Key_50") Then

s:="Yes";

Else

s:="No";

End If;

End Sub Main;

After executing the example a map of strings of random size is generated. Elements with repeated keys are overwritten. The "s" variable contains Yes if element with the Key_50 key exists in the map.

See also:

IStringMap