This refactoring serves the opposite purpose to Convert Indexer (Default Property) to Method. So, it converts:
- A method with return value and a set of parameters to get accessor of an indexer with the same set of parameters.
- A method with a void return type, a set of indexer parameters and a value parameter to set accessor of an indexer.
- Place the caret at the name of a method in the editor, in the File Structure window, in Object Browser or in Class View.
Do one of the following:
- On the main menu, choose ReSharper | Refactor | Convert | Method to Indexer.
- Choose Refactor | Convert | Method to Indexer on the context menu.
- Press Ctrl+Shift+R and click Convert Method to Indexer.
- If no conflicts are found, ReSharper performs the refactoring immediately and the selected method is converted in dialogless mode. Otherwise, resolve conflicts.
Consider the example below:
So the SetMetadata method with a void return type is converted into an indexer with a set accessor.