B
Bernard Bourée
I have a class named "Variable" with 2 properties "Name" and "Value" and
the following class to handle a collection of Variable:
Public Class ColVariables
Inherits CollectionBase
Default Public Property Item(ByVal index As Integer) As Variable
Get
Return CType(List(index), Variable)
End Get
Set(ByVal Value As Variable)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As Variable) As Integer
Return List.Add(value)
End Function 'Add
Public Function IndexOf(ByVal value As Variable) As Integer
Return List.IndexOf(value)
End Function 'IndexOf
............................
My collection is build with:
Dim ColVar as New ColVariables
ColVar.Add(New Variable(Name, Value)
I'm trying to retrieve one item of the collection but the following code
always return -1
Dim var As New Variable(Name, Value)
Dim idx As Integer
idx = ColVar.IndexOf(var)
Idx is always -1
What is wrong ?
the following class to handle a collection of Variable:
Public Class ColVariables
Inherits CollectionBase
Default Public Property Item(ByVal index As Integer) As Variable
Get
Return CType(List(index), Variable)
End Get
Set(ByVal Value As Variable)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As Variable) As Integer
Return List.Add(value)
End Function 'Add
Public Function IndexOf(ByVal value As Variable) As Integer
Return List.IndexOf(value)
End Function 'IndexOf
............................
My collection is build with:
Dim ColVar as New ColVariables
ColVar.Add(New Variable(Name, Value)
I'm trying to retrieve one item of the collection but the following code
always return -1
Dim var As New Variable(Name, Value)
Dim idx As Integer
idx = ColVar.IndexOf(var)
Idx is always -1
What is wrong ?