An interface is implemented at class definition level by using the :
(colon) operator after the class name but before the interface name. Then, you must provide concrete implementations of the methods of that interface. In Visual Studio, this task is automated for you; so, you do not have to type out all the methods.
Steps:
- Type the classname.
- Type the colon (
:
). - Type either
Ctrl+Space
or begin typing the interface name to bring up the IntelliSense menu. Select the interface name from the menu list. - Right click the interface name and select
Implement Interface
from the popup menu.
Figure: Implementing an interface in Visual Studio
No comments:
Post a Comment