Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Implements Statement

Syntax

Implements InterfaceName [,InterfaceName][,...]
InterfaceName (required; String literal)

The name of the interface that a class implements

Description

The Implements statement specifies that you will implement an interface within the class in which the Implements statement appears.

Rules at a Glance

  • Implementing an interface or class means that the implementing class will provide code to implement every Public member of the implemented interface or class. If you fail to implement even a single Public member, an error will result.

  • The Implements statement cannot be used in a standard module; it is used only in class modules.

  • By convention, interface names begin with a capital I, as in IMyInterface.

  • For more information on this topic, see Chapter 4.

Example

Friend Interface IAnimal

   ReadOnly Property Name(  ) As String
   Function Eat(  ) As String
   Function SoundNoise(  ) As String
End Interface

Public Class CWolf
   Implements IAnimal

   Public ReadOnly Property Name(  ) As String _ 
                            Implements IAnimal.Name
      Get
         Return "Wolf"
      End Get
   End Property

   Public Function Eat(  ) As String Implements IAnimal.Eat
      Eat = "caribou, salmon, other fish"
   End Function

   Public Function Sound(  ) As String Implements IAnimal.SoundNoise
      Sound = "howl"
   End Function
End Class

Module modMain

Public Sub Main
   Dim oWolf As New CWolf
   Console.WriteLine(oWolf.Sound)
   oWolf = Nothing
End Sub

End Module

Programming Tips and Gotchas

  • If you do not wish to support a procedure from the implemented class, you must ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata