The .NET Framework provides four very useful generic collections , as enumerated earlier (
Dictionary). The most common case is that
rather than writing your own collection, you’ll use one of the
collection classes provided for you. Each is described in turn in the
next few sections.
The classic problem with the
Array type is its fixed size. If you do not
know in advance how many objects an array will hold, you run the risk
of declaring either too small an array (and running out of room) or
too large an array (and wasting memory).
List class (which
replaces the old non-generic
ArrayList) is, essentially, an array whose
size is dynamically increased as required.
Lists provide a number of useful methods and
properties for their manipulation.. Some of the most important are
shown in Table
Table 14-2. List properties and methods
Method or property
Property to get or set the number of
Property to get the number of elements currently in the list.
Gets or sets the element at the
specified index. This is the indexer for the
Public method to add an object to
Public method that adds the elements of an ...