O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Interfaces

We will show an example of a class implementing the IComparable interface next. Let's assume that you have the class Test, which has a field named m_testNo. You intend to use this class in a sorted collection, which requires the class to implement the IComparable so that it can be sorted by the m_testNo field.

NOTE

We will discuss collections later in the book. The only fact that matters now is that some of them require classes that implement the IComparable interface, which we use as an example.

The next example illustrates this class, implementing the interface IComparable.

Public Class Test
   Implements IComparable Protected m_testNo As Integer Public Property testNo() As Integer Get Return m_testNo End Get Set m_testNo = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required