I often have a specific class, and I also define another class, which is just a collection of another class. For this, it was easiest for me to define another class as Inherits List (Of Type). The reason I define the collection class is to add extra features to the collection. Take the following code for example.
Class Car Property Name As String Property Year As Short Property Model As String End Class Class CarCollection Inherits List(Of Car) Overloads Sub Add(ByVal Name As String, ByVal Year As Short, ByVal Model As String) Dim c As New Car c.Name = Name c.Year = Year c.Model = Model Add(c) End Sub End Class
Now, if I declare a CarCollection variable, how can I refer to Car by name or index, then how .NET seems to make collections. Take for example the .NET ToolStripItemCollection. You can reference elements inside it in one of two ways: MyCollection (2) MyCollection ("MyItemName")
Of course, my question is how can I define my own collection so that I can reference it by index or name. Now I can only refer to the index.
source share