Share via


IDebugMethodField::EnumLocals

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Creates an enumerator for selected local variables of the method.

Syntax

HRESULT EnumLocals(   
   IDebugAddress*     pAddress,  
   IEnumDebugFields** ppLocals  
);  
int EnumLocals(  
   IDebugAddress        pAddress,   
   out IEnumDebugFields ppLocals  
);  

Parameters

pAddress
[in] An IDebugAddress object representing the debug address that selects the context or scope from which to get the locals.

ppLocals
[out] Returns an IEnumDebugFields object representing a list of the locals; otherwise, returns a null value if there are no locals.

Return Value

If successful, returns S_OK or returns S_FALSE if there are no locals. Otherwise, returns an error code.

Remarks

Only the variables defined within the block that contains the given debug address are enumerated. If all locals including any compiler-generated locals are needed, call the EnumAllLocals method.

A method can contain multiple scoping contexts or blocks. For example, the following contrived method contains three scopes, the two inner blocks and the method body itself.

public void func(int index)  
{  
    // Method body scope  
    int a = 0;  
    if (index == 1)  
    {  
        // Inner scope 1  
        int temp1 = a;  
    }  
    else  
    {  
        // Inner scope 2  
        int temp2 = a;  
    }  
}  

The IDebugMethodField object represents the func method itself. Calling the EnumLocals method with an IDebugAddress set to the Inner Scope 1 address returns an enumeration containing the temp1 variable, for example.

See Also

IDebugMethodField
IDebugAddress
IEnumDebugFields
EnumAllLocals