Internal Representation
Arrays provide storage for a number of variables that share a common type. Each element can be indexed by an integral number, both to retrieve it and then replace it. This index is zero-based. To create an array, a length needs to be specified to allocate memory for the contained variables. Note, too, that arrays are reference types, so they’re passed by reference, and different variables can refer to the same array.
To illustrate how arrays are laid out in memory, take a look at Figure 4.30. Notice how the array variable acts as a reference to some other piece of memory containing the elements of the array.
Figure 4.30. Arrays of value types and reference types.
Arrays can be created for value type or reference type ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access