Implementing and Accessing Interfaces

Implementing interfaces means telling a class that it needs to expose all members defined within the interface. You do this by using the Implements keyword followed by the name of the interface. IntelliSense will offer a list of available interfaces, as demonstrated in Figure 13.1. The following code snippet shows how to implement the IDocument interface within a Document class:

Public Class Document    Implements IDocument    Public Property Content As String Implements IDocument.Content    Public Sub Load(fileName As String) Implements IDocument.Load    End Sub    Public Sub Save(fileName As String) Implements IDocument.Save    End SubEnd Class

FIGURE 13.1 Choosing from ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.