RAD Studio (Common)
ContentsIndex
PreviousUpNext
Refactoring: Creating Inline Variables
To create an inline variable:

  1. Select the local variable in the Editor.
  2. On the main menu, choose RefactoringInline variable
    Tip: Alternatively, you can choose Refactoring->Inline variable
    on the context menu. The resulting dialog reports the number of variable occurrences that the Inline Variable command will be applied to.
  3. Click OK to complete refactoring.
Warning: The variable that you select for creating an inline variable, should not be updated later in the source code. If it is, the following error message will display: "Variable index is accessed for writing."
For example, if you use the Inline Variable refactoring command on the local variable index shown below:

public void findIndex() {
                        int index = 2;     
                        System.Console.Writeline("Index is: {0}", index);  
                }

then the following refactoring occurs:

public void findIndex() { 
   System.Console.Writeline("Index is: {0}", 2); 
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!