ReSharper Web Help

The Extract Class From Parameters refactoring allows you to quickly create a new class or structure using (some of) the parameters of a given method. ReSharper analyses the selected method and detects the variables that can be converted into members. After extraction, the new class is created with the necessary fields generated from the selected method's parameters.

To extract a class from parameters
  1. In the editor, position the caret at the name of the method to be used:
  2. On the ReSharper menu or on the context menu, choose Refactor | Extract Class From Parameters
  3. In the Extract Class From Parameters dialog box, click one of the radio buttons in the Create section to specify whether you want to create a class or a structure.
  4. Click a radio button in the Declare as section to specify how you want to declare the new class or structure:
    • Nested means that the class will be declared inside the selected method.
    • Top-level means that the class will be declared inside the class where the method is declared.
  5. In the Name field, enter the new class name.
  6. In the Parameters converted to fields list, check the parameters that will be included in the new class/interface. Use Select All to quickly select all parameters.
  7. Click Next. The new class is created in the same file: