Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Implementing Icomparer (or trying to)

$
0
0

I need to be able to Remove from a Generic List and so must implement an Icomparer.  (I guess today there is a Linq solution to this but I have yet to learn anything about Linq.) 

My problem is that in the code below, although x (in Function Compare) is clearly of type ChangeInfo and Index is clearly Public in my ChangeInfo Class, Intellisense knows nothing about x.Index.  I know that I am following code which I have used before and an example which I found online.  What obvious mistake am I making?  Thanks,  Bob

Public Class ChangeInfo

    Public Index As Integer
    Public Found As Boolean = False  
    Public OldStr As String
    Public NewStr As String
    Public ChangesWhichDGV As DataGridView  
    Public ChangesDGVRow As DataGridViewRow 

    Sub New(ByRef pOldStr As String, ByRef pNewStr As String, pindex As Integer)
        OldStr = pOldStr
        NewStr = pNewStr
        index = pindex
    End Sub
    
    Public Overrides Function ToString() As String
        Return "Rule: " & Index.ToString & " / Old: """ & OldStr & """ / New: """ & NewStr & """"
    End Function
End Class

Public Class EqualityComparerThing
    Implements IComparer(Of ChangeInfo())

    Public Function Compare(ByVal x As ChangeInfo(), _
        ByVal y As ChangeInfo()) As Integer _
        Implements IComparer(Of ChangeInfo()).Compare

        If x.index = y.index Then

        End If

    End Function

End Class



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>