JetBrains Rider
 
Get JetBrains Rider
You are viewing the documentation for an earlier version of JetBrains Rider.

Introduce Variable refactoring

Last modified: 08 March 2021

Refactor | Introduce Variable...

N/A

This refactoring allows you to create a new local variable or constant based on a selected expression, initialize it with the expression, and finally replace all occurrences of the expression in the method with references to the newly introduced variable.

In the example below, we use this refactoring to replace two occurrences of the same string with a variable: