Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Refactor Code with Extract Interface 

Use this procedure to perform the Extract Interface refactoring operation.

To use Extract Interface

  1. Create a console application as described in the example below.

    For more information, see Console Application.

  2. With the cursor positioned in MethodB, select Extract Interface on the Refactor menu. The Extract Interface Dialog Box appears.

    You can also type the keyboard shortcut CTRL+R, CTRL+I to display the Extract Interface Dialog Box.

    You can also right-click the cursor, point to Refactor on the context menu, and then click Extract Interface to display the Extract Interface Dialog Box.

  3. Click Select All.

  4. Click the OK button.

    You see the new file, IProtoA.cs, and the following code:

    using System;
    namespace TopThreeRefactorings
        interface IProtoA
            void MethodB(string s);


To set up this example, create a console application named ExtractInterface, and then replace Class1 with the following code. For more information, see Console Application.

    // Invoke Extract Interface on ProtoA.
    // Note:  the extracted interface will be created in a new file.
    class ProtoA
        public void MethodB(string s) { }

See Also

Community Additions

© 2015 Microsoft