Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Interfaces

It is useful to make a distinction between a class’s interface and its implementation. Conceptually, the interface of a class is the set of members that are visible to users of the class—i.e., the class’s public members. The public members are thought of as comprising the class’s interface because they are the only way that code outside of the class can interact (i.e., interface) with objects of that class. In contrast, the implementation is comprised of the class’s code plus the set of members that are not public.

It is possible to take this interface concept further and separate interface definition from class definition altogether. This has benefits that will be shown shortly. To define an interface, use the Interface statement:

Public Interface ISomeInterface
   Sub SomeSub(  )
   Function SomeFunction(  ) As Integer
   Property SomeProperty(  ) As String
   Event SomeEvent( _
      ByVal sender As Object, _
      ByVal e As SomeEventArgs _
   )
End Interface

An interface declaration defines methods, properties, and events that will ultimately be implemented by some class or structure definition. Because interfaces never include any implementation, the declarations are headers only—never any implementation code; End Sub, End Function, or End Property statements; or property get or set blocks. There are no access modifiers (Public, Private, etc.) because all members of an interface are public by definition. By convention, interface names start with the letter “I”.

To provide an implementation ...

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

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata