Inline Temp
- 2 minutes to read
Purpose
This Refactoring replaces all references to a local variable with its initial value.
You may find a variable in your code whose value does not change and the meaning is trivial. If this variable is not commonly used, you can eliminate it by executing the Inline Temp Refactoring.
Availability
Available when the cursor is on a local variable declaration or reference assuming the variable does not change.
Usage
Place the caret on a local variable whose value does not change.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Inline Temp from the menu.
After execution, the Refactoring replaces the variable references with its initial value and removes the initialization.
float CalculateDiscount(float price) {
int percentage = GetCurrentDiscount();
return price - (float)percentage / 100 * price;
}
See Also