Extract Field refactoring

The Extract Field refactoring creates a field that holds the selected expression as the value and replaces its occurrences by reference to this newly created field. You can replace all the occurrences of the expression or only the one at the caret.

To invoke the refactoring, select an expression to be replaced with a field or place the caret over an expression and press &shortcut:IntroduceField; (Refactor | Extract | Field):

Extract field