Transform Out Parameters refactoring
This refactoring lets you get rid of out parameters of a method.
If the method's return type is
and a single out parameter is transformed,
ReSharper moves the out value to the method's return.
Otherwise, ReSharper creates a
Tuple object to combine all return values.
In any case, all method calls are updated accordingly.
The example below illustrates the first case, when the
out parameter is replaced with method's return:
If the method needs to return more than one value, a
Tuple object is created:
To transform out parameters
Place the caret at the declaration or a usage of method in the editor,
or select the method in the
File Structure Window.
Or, alternatively set the caret at the
outkeyword or at the name of an out parameter.
Do one of the following:
- Press Ctrl+Shift+R and then choose Transform Out Parameters
- Right-click and choose Refactor | Transform Out Parameters on the context menu.
- Choose in the main menu.
- Select the parameters you want to transform. According to the selected parameters, a new signature is displayed in the bottom of the refactoring dialog.
- To apply the refactoring, click Next.
- If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
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.