Declare Local

Generates a local variable of the appropriate type for the current reference.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on an undeclared variable reference.

Example

private int TestMethod(int param)
{
    return param * multiplier;
}
Private Function TestMethod(ByVal Param As Integer) As Integer
    Return Param * Multiplier
End Function

Result:

private int TestMethod(int param)
{
    int multiplier = 0;
    return param * multiplier;
}
Private Function TestMethod(ByVal Param As Integer) As Integer
    Dim Multiplier As Integer = 0
    Return Param * Multiplier
End Function