34,333
edits
Changes
no edit summary
Arrays are certainly not unique to C#, in fact just about every other programming and scripting language preceding the introduction of C# provided support for arrays. An array allows a collection of values of the same time type to be stored and accessed via a single variable. Each item is accessed in the array variable through the the use of an ''index'' value into the array.
C# arrays, whilst useful, have some limitations. Perhaps the most significant limitations are limitation is the fact that once an array has been created it cannot be made larger or smaller to accommodate more or fewer values. For more dynamic and flexible collection storage capabilities, it is worth also reading about [[C Sharp Collection Classes|C# Collection Classes]].
== Creating Arrays in C# ==
</pre>
This will reserve the space required for the fulkl full array without actually placing any values into the array. Finally, this approach may also be combined with the comma separated value list (although the number of values must match the size specified):
<pre>
== Accessing Array Values ==
Once values have been stored in an array it is highly likely that these values will need to accessed at some later point in the C# code. This is achieved using the ''array accessor'' notation combined with the index into the array of the desired value. The ''array accessor'' is simply the array name followed by square brackets. Within the square brackets is placed a number representing the index into the array of the desired value (keeping in mind that the first array element in C# is index 0). For example, to access the second element of our ''myColors'' array the following notation would be used:
<pre>
</pre>
The order of the elements may subequently subsequently be reversed using the ''System.Array.Reverse()'' method:
<pre>