ReSharper Web Help

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
  1. Place the caret at the name of an iterator in the editor, in the File Structure window, in Class View or in Object Browser.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Convert | Iterator to Method.
    • 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.

See Also