I’m trying to work out how to retrieve an object from a collection in VB 2008.
The class defining the object is called Predator and has three public properties:
strName (string)
strKind (string)
blnIsBig (boolean)
example “Dogfish”, “Shark”, False
I have a collection class called PredatorCollection. There is no problem adding Predator objects to it using the Add method:
Dim Predator1 As New Predator(“Dogfish”, “Shark”, False)
PredatorCollection.Add(Predator1).
What I am trying to do is retrieve the strName property from the the last object in the collection. If I key:
PredatorCollection.Item(PredatorCount).
Intellisense gives me 5 options; Equals, GetHashCode, GetType, ReferenceEquals and ToString. I suspect ToString is the one to use, but it gives a concatenation of all the properties in the object. I only want strName. There must be a way to do it!