Convert Iterator to Method
The Convert Iterator to Method refactoring provides an opportunity to transform an iterator into a block of code that uses an explicit collection holding iteration result.
To convert an iterator to a method
- Place the caret at the name of an iterator in the editor, in the File Structure window, in Class View or in Object Browser.
Do one of the following:
- On the main menu, choose .
- Choose Refactor | Convert | Iterator to Method on the context menu.
- Press Ctrl+Shift+R and click Convert Iterator to Method.
Consider the example below: After applying the refactoring, you are prompted to specify a name for the collection that holds the result.
This feature is supported in the following languages/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.