title | description | ms.date | ms.topic | helpviewer_keywords | author | ms.author | manager | ms.subservice | ||
---|---|---|---|---|---|---|---|---|---|---|
Implement an Interface (Class Designer) |
Learn how to implement an interface on the class diagram by connecting it to a class that provides code for the interface methods. |
11/04/2016 |
how-to |
|
ghogen |
ghogen |
mijacobs |
general-ide |
In Class Designer, you can implement an interface on the class diagram by connecting it to a class that provides code for the interface methods. Class Designer generates an interface implementation and displays the relationship between the interface and the class as an inheritance relationship. You can implement an interface by drawing an inheritance line between the interface and the class or by dragging the interface from Class View.
Tip
You can create interfaces the same way you create other types. If the interface exists but does not appear on the class diagram, then first display it. For more information, see Create types by using Class Designer and View existing types.
-
On the class diagram, display the interface and the class that will implement the interface.
-
Draw an inheritance line from the class and the interface.
A lollipop appears attached to the class and a label with the interface name identifies the inheritance relationship. Visual Studio generates stubs for all interface members.
For more information, see Create inheritance between types.
-
On the class diagram, display the class that you want to implement the interface.
-
Open Class View and locate the interface.
[!TIP] If Class View is not open, open Class View from the View menu or press Ctrl+Shift+C.
-
Drag the interface node to the class shape on the diagram.
A lollipop appears attached to the class and a label with the interface name identifies the inheritance relationship. Visual Studio generates stubs for all interface members; at this point, the interface is implemented.