Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Multi-Dimensional Arrays

 

A multi-dimensional array  of dimension n (i.e., an n-dimensional array or simply n-D array) is a collection of items which is accessed via n subscript expressions. For example, in C# the tex2html_wrap_inline60233 element of the two-dimensional array x is accessed by writing x[i,j].

The built-in multi-dimensional arrays suffer the same indignities that simple one-dimensional arrays do: Array indices in each dimension range from zero to tex2html_wrap_inline60155, where Length is the array length in the given dimension and the number of dimensions and the size of each dimension is fixed once the array has been allocated.

In order to illustrate how these deficiencies of the C# built-in multi-dimensional arrays can be overcome, we will examine the implementation of a multi-dimensional array class, MultiDimensionalArray, that is based on the one-dimensional array class discussed in Section gif.




next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.