Refactoring - Creating Inline Variables
Go Up to Refactoring Procedures Index
This topic explains how to use the "Inline variable" operation.
To create an inline variable:
- Select the local variable in the Code Editor.
- On the main menu, choose  Refactor > Inline variable.
 The resulting dialog reports the number of variable occurrences that the Inline Variable command will be applied to.Tip: Alternatively, you can choose Refactor > Inline variable on the context menu. 
- 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);
}