Creating a Strongly-Typed Collection

The collections you have been looking at in this chapter are generic in that they can store heterogeneous instances of any object type or boxed value type. Most likely, you might need to create a collection that stores data of only one type. This is called a strongly typed collection.

Descending from CollectionBase

The System.Collections namespace contains an abstract class, CollectionBase, from which your custom collection might descend in order to create strongly-typed collections. Internally, the CollectionBase uses an ArrayList instance to store elements. Access to the ArrayList is through an IList interface provided by the List property. CollectionBase also defines the methods that need to be overridden ...

Get Delphi for .NET Developer’s Guide 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.