Reorder Parameters
- 2 minutes to read
Purpose
This Refactoring is used to change the method parameter order and automatically update all method references. Use it when you need to standardize the method signature or make the parameters order more logical.
Note
The Reorder Parameters refactoring is not available for methods declared in the third party assembly.
Availability
Available when the caret is on a method parameter in the method declaration or call.
Usage
Place the caret on a method parameter.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
static Tuple<double, double> Undistort(Tuple<int, int> point, double k1, double k2, double │k3, double p1, double p2) { // ... return Tuple.Create((double)point.Item1, (double)point.Item2); } static void Main(string[] args) { // ... Undistort(Tuple.Create(145, 21), -0.460891, 1.95183, -4.16323, -0.000516346, 0.00354672); }
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Reorder Parameters from the menu.
After execution, the graphical reordering interface turns on. Use the “<— (Left Arrow)” and “—> (Right Arrow)” keys to move the selected parameter across the method signature. Press Enter to confirm the new parameter location.
After you finish the graphical reordering, the code fill be updated according to the desired method signature.
static Tuple<double, double> Undistort(Tuple<int, int> point, double k1, double k2, double p1, double p2, double k3) {
// ...
return Tuple.Create((double)point.Item1, (double)point.Item2);
}
static void Main(string[] args) {
// ...
Undistort(Tuple.Create(145, 21), -0.460891, 1.95183, -0.000516346, 0.00354672, -4.16323);
}