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.
NoteIf the selected field has more than one write usage, ReSharper reports a conflict.
- Choose ReSharper | Refactor | Inline, or press Ctrl+Alt+N. If no conflicts are discovered, ReSharper inlines the field immediately.
For example, the following field is initialized when it's declared and it doesn't have any other write
Here's a read usage of the field before applying the refactoring:
After inlining the field, ReSharper creates local variables to hold initialization expression of the refactored field, and substitutes read usages of the field with read usages of the variables: