ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Convert Indexer to Method refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Convert | Indexer to Method…

To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_Indexer2Function command.

This refactoring helps you convert one or both accessors of an indexer into methods and update usages of the indexer in the current solution accordingly.

In the example below ReSharper converts both getter and setter accessors of the indexer and updates the usage:

ReSharper refactorings: Convert indexer to method

This feature is supported in the following languages and technologies:

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