Export (0) Print
Expand All

How to: Reorder Parameters 

You can change the order of parameters for methods, indexers, constructors and delegates, and automatically update their call sites using the Reorder Parameters refactoring operation.

To Reorder Parameters

  1. Create a Class Library and set it up as described in the example section below.

  2. Place the cursor on MethodB, either in the method declaration or the method call.

  3. On the Refactor menu, click Reorder Parameters.

    — or —

    Type the keyboard shortcut CTRL+R, CTRL+O to display the Reorder Parameters Dialog Box.

    — or —

    Right-click the cursor, point to Refactor on the context menu, and then click Reorder Parameters to display the Reorder Parameters Dialog Box.

    The Reorder Parameters Dialog Box appears.

  4. In the Reorder Parameters dialog box, select int i in the Parameters list. Then click the down button.

    — or —

    Drag int i below bool b in the Parameters list.

  5. In the Reorder Parameters dialog box, click OK.

    If the Preview reference changes option is selected in the Reorder Parameters dialog box, then the Preview Changes - Reorder Parameters dialog box will appear. It provides a preview of the changes in the parameter list for MethodB in both the signature and the method call.

    1. If the Preview Changes - Reorder Parameters dialog box appears, then click Apply.

In this example, the method declaration and all of the method call sites for MethodB are updated.

Example

To set up this example, create a class library named ReorderParameters, and then replace Class1 with the following code.

    class ProtoClassA
    {
        // Invoke on 'MethodB'.
        public void MethodB(int i, bool b) { }
    }

    class ProtoClassC
    {
        void D()
        {
            ProtoClassA MyClassA = new ProtoClassA();

            // Invoke on 'MethodB'.
            MyClassA.MethodB(0, false);
        }
    }

See Also

Community Additions

ADD
Show:
© 2014 Microsoft