The Transform Out Parameters refactoring lets you get rid of out parameters in methods and consequently improves readability of your code.
- Place the caret at the name of a method, at the out keyword or at the name of an out parameter in the editor or select the method in the File Structure window.
Do one of the following:
- On the main menu, choose ReSharper | Refactor | Transform Out Parameters.
- Right-click, then click Refactor | Transform Out Parameters on the context menu.
- Press Ctrl+Shift+R, then click Transform Out Parameters.
The Transform Out Parameters dialog box opens:
Select the appropriate check boxes nearby the parameters. According to the selected check boxes, a new signature is displayed in the Transform to text area.
- Click Next.
After applying the refactoring two kinds of results are possible:
- If the return type of a method is void and only one out parameter is being transformed, ReSharper changes the method so that it simply returns the value of this parameter.
- If the return type of a method is not void or more than one out parameter are being transformed, ReSharper uses the Tuple type.