NamedObjectCollectionBase—Making Your Own Collections

All the collections you have seen so far can be used as they are—that is, out of the box. This is a good thing, but it has its price: None of these collections are strongly typed, meaning that the methods of the collection use Object base class references in all methods. This means that you can easily make a mistake and pass in the wrong type of object, and the compiler would not be able to tell you that you made a mistake. This is sometimes an acceptable risk, especially if the code that deals with a collection is contained. However, there are cases when you need to expose collections of some of your objects to the outside world. Exposing an ArrayList of Person objects, say, would allow a ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.