ReSharper 8.0 Web Help

The Introduce Field refactoring allows you to create a new field based on a selected expression, initialize it with the expression, and replace occurrences of the expression in the code with references to the newly introduced field.

To introduce a field
  1. Select an expression in the editor.
  2. Do one of the following:
    • On the main menu, choose ReSharper| Refactor | Introduce Field.
    • Choose Refactor | Introduce Field on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Introduce Field.
    • Press Ctrl+Alt+DCtrl+R,F.
  3. If more than one occurrence of the selected expression is found, ReSharper displays the drop-down menu. Choose whether to replace all occurrences or only the selected one.


  4. The Introduce Field dialog box opens. Type the name of a new field in the Name text box or leave the default one.


  5. Select an option in the Introduce field and initialize in section:
    • Current member: initializes the field in the current member (this option is only available if you chose to replace a single occurrence or occurrences within the current member).
    • Field initializer: initializes the field right where it is declared.
    • Constructor(s): initializes the field in the constructor or constructors of the containing class; if necessary, creates a parameterless constructor and initializes the field from within it.
    • Introduce constant: creates a constant instead of a field.
  6. In the Visibility drop-down list, select the visibility of the new field.
  7. Select the Make static check box to create a static field.
  8. Select the Make field read-only check box to create a read-only field.
  9. Click Next. The new field is created and initialized according to specified settings. One or more occurrences of the selected expression are replaced with usages of the field.

This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available


The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.