Share via


Map.lookup(Object) Method

Definition

Returns the value that is mapped to by a specified key value.

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

Parameters

_keyValue
Object

The key to find.

Returns

The value that is mapped to by the specified key.

Remarks

An exception is thrown if the key is not found in the map, so check whether the value that you want to retrieve exists by using the Map.exists method.

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