Changes

Jump to: navigation, search

Introducing C Sharp Arrays

18 bytes added, 18:30, 1 April 2009
no edit summary
</pre>
Another option is to declare the size of the array when it is created. For example, to declare an array of size 10 simply place the the size value within the square brackets of the new statement:
<pre>
== Accessing Array Values ==
<google>ADSDAQBOX_FLOW</google>
Once values have been stored in an array it is highly likely that these values will need to be 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>
When executed, the above code will output the work word "green" since this is the string contained at index 1 position in the array.
Similarly, the value at a particular index point in the array may be changed using the accessor notation combined with the assignment operator (=). For example, to change the value of the first item in the array:
</pre>
Values in a multidimensional array may be accessed by specifying the index values for each dimension separated by commas. For example, to access the author (index position 1 of the second dimension)of the book located at index position 2 of the first dimension in our multidimensional array:
<pre>

Navigation menu