June 2003
Intermediate to advanced
800 pages
34h 20m
English
You need to create a collection that can only contain one type of object and rejects attempts to add other data types.
Create a custom collection class by deriving from System.Collections.CollectionBase, and implement type-safe Add, Remove, and Item methods.
You could create a custom collection by implementing the IList, ICollection, and IEnumerable interfaces. However, .NET provides an easier option with the abstract CollectionBase class. Internally, the CollectionBase uses an ArrayList, which is exposed through the protected property List.
As an example, consider the simple Customer object shown here:
Public Class Customer Private _ID As Integer Private _FirstName As String Private _LastName ...
Read now
Unlock full access