ReSharper Web Help

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

To inline a variable
  1. In the editor, place the caret at the name of the variable.
  2. On the ReSharper menu or context menu, choose Refactor | Inline, or press Ctrl+Alt+N. The variable will be inlined immediately.

Consider the following example:

After we inline the variable k, ReSharper modifies the code in the following way:

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.

See Also