When a field has a single write usage, this dialogless refactoring:
- Creates new local variables holding initialization expression of the field to substitute its read usages.
- Deletes the field declaration and the write usage.
- Position the caret at a field that has exactly one write usage.
- On the main menu, choose ReSharper | Refactor | Inline, or press Ctrl+Alt+N. If the selected field has more than one write usage, ReSharper reports a conflict. Otherwise, ReSharper inlines the field immediately.
For example, the following field is initialized when it's declared and it doesn't have any other write usages:
Two read usages of the field are found and highlighted:
After applying the refactoring, ReSharper creates a local variable to hold initialization expression of the field, and substitutes read usages of the field with read usages of the variable: