Let’s check today a nice feature from Visual Studio 2008 from the refactor feature: Generating an interface from an existing class.
For this example, we are going to use the following class:
- To extract an interface, right-click anywhere in the class and select Refactor > Extract Interface;
- The Extract Interface window is displayed. Enter the interface name, the file name, select the members that form the interface and click ok;
- The interface is generated;
- The original class has its signature changed to implement automatically the interface;