ReSharper Web Help

This refactoring is available in: ReSharper Full Edition and ReSharper C# Edition

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. Position the caret at the name of a static method that meets the above requirements, or select it in File Structure.
  2. Choose ReSharper | Refactor | Convert | Static to Extension Method.
  3. The refactoring will be carried out without requiring you to specify any further options.

Consider the following method declaration:

and its usage:

After converting it to an extension method, its signature will receive an additional this parameter:

and it will be called like a common instance method:

See Also