Armin,
I always had the idea that the Arraylist was a kind of base from the generic
list (I did not even investigate it, but it is not)
However I took your code and was trying also the new From in version VB10 a
little bit deeper, here the sample,
you see no continuation characters in this code, not forgotten,
they are for this code not needed anymore.
Module Module1
Sub Main()
Dim pholding As New List(Of Person) From
{New Person With {.name = "armin"},
New Person With {.name = "dan"},
New Person With {.name = "cor"}}
Console.Write(pholding.FindIndex(Function(person) person.name =
"dan"))
Console.ReadLine()
End Sub
End Module
Public Class Person
Public Property name As String
End Class
Cor
"Armin Zingler" wrote in message
Am 11.10.2010 21:36, schrieb Dan Smith:
Cor,
Thanks for the response. Unfortunately The objects stored in the arraylist
are all dynamically placed and I don't know how many objects are going to
be added each time the program runs.
What I unfortunately had to do was create a loop and track the loop count
until I found what I wanted:
Dim pholding As New ArrayList
Dim persons As person
Dim i as integer
Dim j as integer
For Each person In pholding
i+= 1
If persons.name = input.text then
j = i
end if
Next persons
Is there any cleaner way of doing this?
Not with the ArrayList. As Cor said, depending on the language version,
you can use a generic list:
Dim pholding As New List(Of person)
Dim index As Integer
'...
index = pholding.FindIndex(Function(person) person.name = input.text)