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 = ...

Get Visual Basic® .NET by Example 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.