The Inline Variable refactoring allows you to replace all occurrences of a given variable in the code with its initializer.
- Place the caret at the name of a variable in the editor.
-
Do one of the following:
- On the main menu, choose ReSharper| Refactor | Inline.
- Choose Refactor | Inline on the context menu.
- Press Ctrl+Shift+R, then click Inline Variable.
- Press Ctrl+Alt+N.
- The variable will be inlined immediately.
Consider the example below:

After applying the refactoring, the usage of the r variable
is replaced with its initialisation expression.

The Inline Variable refactoring can only be applied
to variables if their values keep unchanged after initialization. If a
variable violates this condition, an error is reported.
