No. Arrays are never open-ended; their dimensions are even
immutable (please see below).
It simply means that the dimensions of the array are not known at the point of the array variable declaration, but then the array object is never created. When you create an array object itself using
new
, you always pass dimensions to it, and since that the array dimensions cannot be modified.
Why using an unknown dimensions then? Oh, this is very important.
This is the abstract interface to a variable. [EDIT] First of all, the variable declaration declared the array
rank (number of indices to be use, 2 in case of [,], 3 for [,,], etc.); I'm adding this explanation thanks to the good comment by Matt T Heffron (see comments below); thank you, Matt. [END EDIT]. The dimensions can be variables. For example, you create an array in a method, so, in one call, you create the actual object with one set of dimensions, in other call, with different dimensions. When you use the variable referencing already created array object, you inquire about actual dimensions from the array object itself:
http://msdn.microsoft.com/en-us/library/system.array.length.aspx[
^],
and, in case of rank > 1:
http://msdn.microsoft.com/en-us/library/system.array.getlowerbound.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.array.getupperbound.aspx[
^].
And, be careful with
System.Array.Resize
:
the array is never actually resized: in fact, a brand-new array object is created, available data is copied from "old" array object to "new" one and returned. If you overwrite the variable with this brand-new array, "old" array object will eventually be garbage-collected.
[EDIT]
For open-ended data structures, you can use
collections:
http://msdn.microsoft.com/en-us/library/system.collections.aspx[
^],
mostly
http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx[
^].
Basically, that's all you need to know.
—SA