The FCL provides a reasonably comprehensive set of prebuilt data structures
providing concrete implementations of all the interfaces described in this
chapter. However, since C# does not yet support generics, the implementations
work in terms of the generic object type, which has the same disadvantages
(excessive casting, boxing) as the generic
described earlier. If you prefer more type-safe collection classes, you may
use one of these predefined types as a starting point for your own type-safe
Array class is the canonical aggregate data structure
in the FCL, representing a fixed-size array of object references of uniform
type. Since the
Array data structure is fundamental,
the C# language provides explicit array declaration and initialization syntax
(for more details, see Chapter 2 and Chapter 3). The storage for the array is allocated
on the GC heap at the time a class is instantiated, and cannot change (see
ArrayList class for a growable array-like data structure).
Array class implements
IEnumerable, so arrays can be treated as lists, generic
cloneable collections, or sets of elements that can be enumerated.
In addition, the
Array class supports sorting and searching
of the array. Sorting of the array is often accomplished by delegating to
on the contained elements, which requires that you implement
IComparable on types that are intended for ...