Inline Field refactoring
This refactoring helps you replace a field with its value and remove its declaration. For obvious reasons, the refactoring can be applied to a field that has only one write usage. This may be a constant or readonly field, or a field that is initialized and used in the same function.
If the target field has conditional or complex assignment and it is used within a single function, ReSharper will create a local variable to handle the value of the field.
In the example below, we use this refactoring to inline a constant that has a single usage:
Inline a field
Place the caret at the declaration or a usage of a field, which has only one write usage.
Do one of the following:
Press Control+Alt+N and then choose Inline Field
Press Control+Shift+R and then choose Inline Field.
Right-click and choose Refactor | Inline Field from the context menu.
Choosefrom the main menu.
If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
This feature is supported in the following languages and technologies:
The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.