Information Technology Reference
In-Depth Information
An Array As an Object
An array instance is an object whose type derives from class System.Array . Since arrays are
derived from this BCL base class, they inherit a number of useful members from it, such as
￿ Rank : A property that returns the number of dimensions of the array
￿ Length : A property that returns the length of the array (the total number of elements in
the array)
Arrays are reference types, and as with all reference types, have both a reference to the
data and the data object itself. The reference is in either the stack or the heap, and the data
object itself will always be in the heap. Figure 14-3 shows the memory configuration and com-
ponents of an array.
Figure 14-3. Structure of an array
Although an array is always a reference type, the elements of the array can be either value
types or reference types.
￿
An array is called a value type array if the elements stored are value types.
￿
An array is called a reference type array if the elements stored in the array are references
of reference type objects.
Figure 14-4 shows a value type array and a reference type array.
Figure 14-4. Elements can be values or references.
Search WWH ::




Custom Search