Share via


Map.exists(Object) Method

Definition

Determines whether a particular value exists as a key in the map.

public:
 bool exists(System::Object ^ _keyValue);
public bool exists (object _keyValue);
member this.exists : obj -> bool
Public Function exists (_keyValue As Object) As Boolean

Parameters

_keyValue
Object

The value to check for.

Returns

true if the specified key value exists in the map; otherwise, false.

Remarks

Use this method to guard calls to the Map.lookup method. If the Map.lookup method does not find the value that it is looking for, it throws an exception.

The following example checks whether a particular style exists in a map of styles in a style sheet. If it does, a new name is substituted for the body style.

static void renameStyle(Map stylesheet, str fromName, str toName) 
{ 
    str body; 
    if (stylesheet.exists(fromName)) 
    { 
        body = stylesheet.lookup (fromName); 
        stylesheet.remove (fromName); 
        stylesheet.insert (toName, body); 
    } 
    else 
    { 
        info (fromName); 
    } 
}

Applies to