"Create .NET Custom Collections" by Francesco Balena
Visual Studio Magazine, October 2002


The companion code for this article include two console applications, one in VB.NET and the other in C#. The two applications are identical, except for the language used.

The source code contains all the custom collection classes described in the article:

*) Invoice, InvoiceLine, and InvoiceLineCollection - the latter is a collection class that derives from CollectionBase and implements the one-to-many relationship between Invoice and InvoiceLine

*) TextLineCollection derives from ReadOnlyCollectionBase and shows how you can parse a text file one line at a time by using a for each statement

*) PersonDictionary derives from DictionaryBase and implements a hashtable-like structure that can contain only Person objects. 

*) PersonCollection derives from NameObjectCollectionBase and shows how to implement a VB6 collection-like collection that can contain only Person objects

*) FileReader is a collection built on the IEnumerable and IEnumerator interfaces. It is similar to TextLineCollection, but it is more efficient because each line is read from file only when the main program requests it

