The requested page is not available for the requested platform. You are viewing the content for Default platform.

Rename

  • 2 min to read

Renames a local variable, function, method, field, property, parameter, type, namespace, active CSS style, XAML namespace prefix, C++ global variable, or C++ macro and updates all references to the modified element.

Purpose

Providing a meaningful name for a variable, property or method can greatly improve code readability.

Availability

Available from the context menu or via shortcuts:

  • when the edit cursor or caret is on a local variable, private field, private property or private method declaration or reference.
Note

If you need to rename a public method, take a look at the Safe Rename refactoring.

Notes

  • When the Rename is activated, it turns all references to the selected variable into the linked identifiers.
  • Rename is automatically activated by a number of other refactorings that introduce new variables, constants, methods and properties. This enables you to give a meaningful name to a newly declared member.
  • The JavaScript language structure does not always permit you todefinitely determine whether two elements are in fact references to the same identifier or if they just have the same name. The Confirm Changes window gives you full control over renaming JavaScript identifiers. This window appears when the Rename refactoring is about to be applied and enables you to ensure that only the desired references will be renamed. You can omit a reference that should not be renamed by clearing the check from the appropriate item.

    ConfirmChangesWindow

Example

private string fName;
private string Name
{
    get
    {
        return fName;
    }
    set
    {
        fName = value;
    }
}
Private fName As String
Private Property Name() As String
    Get
        Return fName
    End Get
    Set(ByVal value As String)
        fName = value
    End Set
End Property

Result:

private string NewName;
private string Name
{
    get
    {
        return NewName;
    }
    set
    {
        NewName = value;
    }
}
Private NewName As String
Private Property Name() As String
    Get
        Return NewName
    End Get
    Set(ByVal value As String)
        NewName = value
    End Set
End Property

Screenshot

rsRenameCSharp

See Also