ReSharper Web Help

This refactoring converts a static method to an extension method, given that the static method:

  • Has at least one argument.
  • Resides in a static class.

The refactoring works in dialogless mode.

The reverse functionality is available with the Convert Extension Method to Plain Static refactoring.

To convert a static method to an extension method
  1. Place the caret at the name of a static method that meets the above requirements, or select it in the File Structure window, in Object Browser or in Class View.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Convert | Static to Extension Method.
    • Choose Refactor | Convert | Static to Extension Method on the context menu.
    • Press Ctrl+Shift+R, then click Convert Static to Extension Method.
  3. The refactoring is carried out without requiring you to specify any further options.

Take a look at the following method declaration:

and its usage:

After converting it to an extension method, an additional this parameter is added to the signature:

and it is called like a common instance method:

See Also

Procedures