JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 2025.1! Learn more

Inline Field refactoring

Last modified: 23 September 2024

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, JetBrains Rider 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: