ReSharper 8.0 Web Help

The Inline Variable refactoring allows you to replace all occurrences of a given variable in the code with its initializer.

To inline a variable
  1. Place the caret at the name of a variable in the editor.
  2. Do one of the following:
    • On the main menu, choose ReSharper| Refactor | Inline.
    • Choose Refactor | Inline on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Inline Variable.
    • Press Ctrl+Alt+NCtrl+R,I.
  3. 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.

This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available


The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.