' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Collections

Namespace E
    Public Class Foobar
        Private iv As Integer
        Private sv As String
        Public Sub New()
            MyClass.New(0, "")
        End Sub
        Public Sub New(ByVal iv As Integer)
            MyClass.New(iv, "")
        End Sub
        Public Sub New(ByVal iv As Integer, ByVal sv As String)
            Me.iv = iv
            Me.sv = sv
        End Sub
        Public Overloads Overrides Function ToString() As String
            Return ("[" & iv & "," & sv & "]")
        End Function
        Public Overloads Overrides Function Equals(ByVal o As Object) As Boolean
            Return (iv = CType(o, Foobar).iv)
        End Function
        Public Overloads Overrides Function GetHashCode() As Integer
            Return iv.GetHashCode
        End Function
    End Class 
    Class MainClass
        Public Shared Sub Main(ByVal args As String())
            Dim lst As ArrayList = New ArrayList
            lst.Add(New Foobar(1, "A"))
            lst.Add(New Foobar(2, "BB"))
            lst.Add(New Foobar(3, "CCC"))
            Dim ix As Integer = lst.IndexOf(New Foobar(2))
            If ix >= 0 Then
                Console.WriteLine(lst(ix))
            Else
                Console.WriteLine("Not found")
            End If
        End Sub
    End Class 
End Namespace
