Implementation of CompareTo in user-defined class

onny_paiki

New member
Joined
Apr 2, 2006
Messages
2
Programming Experience
Beginner
Hi all Look, I have a little problem. I create a class "TermCluster" that contains an ArrayList object as you see below. Well, I'm new at VB.Net programming.

VB.NET:
Public Class TermCluster 
   Implements IComparable 

[INDENT]Dim oArRelatedTerm As New ArrayList 
Dim oSimilarity As Double 

Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo 
[INDENT]If TypeOf obj Is TermCluster Then 
   Dim tmp As TermCluster = CType(obj, TermCluster) 
   If Me.oArRelatedTerm.Equals(tmp.oArRelatedTerm)     Then 
      Return 0 
   Else 
      Return 1 
   End If 
End If 
[/INDENT]End Function 
[/INDENT]End Class

The problem is there are similar objects of TermCluster considered different from each other. Well, if you can help me, please reply. Thanx.
 
Last edited:
Back
Top