Unlike Visual Basic the C# language does not provide a standard mechanism for re-dimensioning (resizing) arrays. This component provides that additional functionality for arrays created in C#.
The ArrayObject component is able to resize two and three dimensional rectangular arrays. You can also resize jagged arrays by re-dimensioning each array in the jagged array separately. Unlike Visual Basic the ArrayObject always preserves the information present in the original array.
The ArrayObject lives inside the Redhotglue.Utilities.Extra namespace and contains only one method, the ReDimension() method.
|
Resizing a single column array
If for example you had created an array with a single column like this:
|
Using the ArrayObject you can resize this array by declaring a new instance of the ArrayObject and calling its ReDimension() method.
|
or:
|
Resizing a two dimensional rectangular array
For a two dimensional rectangular array,
|
Using the ArrayObject you can resize this array in much the same way as is done for a single column array. The difference here is that you provide the lengths for both dimensions (number of columns and rows).
|
or:
|
Resizing a three dimensional rectangular array
For a three dimensional rectangular array,
|
Using the ArrayObject you can resize this array in much the same way was done previously. The difference here again is that you provide the lengths for all three dimensions (1st dimension, 2nd dimension, 3rd dimension).
|
|
or:
|
NewArray = objArray.ReDimension(OldArray, 10, 10, 10);
Resizing a jagged array
Using the ArrayObject you can resize the individual arrays of a jagged array. By resizing the arrays individually you are able to resize a jagged array of any dimension.
|
or:
|
Comments
Join the conversation! Your thoughts help the community grow.