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

Extending C# Arrays

 

While the C# programming language does indeed provide built-in support for arrays, that support is not without its shortcomings: Array indices range from zero to n-1, where n is the array length and the size of an array is fixed once allocated.

One way to address these deficiencies is to define a new class with the desired functionality. We do this by defining a DynamicArray class with two fields as shown in Program gif. The first is an array of C# objects and the second is an int which records the lower bound for array indices.

   program2683
Program: DynamicArray fields.


next up previous contents index

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