Under the covers, arrays in AVR are instances of .NET’s System.Array class. As such, there are a bevy of methods you can use to work with arrays. There are also a few properties that are handy. Click here to read details about all the methods and properties arrays provide. Here is a quick overview of the most-used methods and properties:

Array methods

Array properties

Traversing an array

You can see array methods in action when you investigate the ways AVR for .NET lets you traverse an array. There are at least four ways to do this.

Consider this array declaration:

You could traverse this array with a Do loop using a hard-coded upper bound:

You could also traverse this array with a Do loop using a soft-coded upper bound this way:

With the above method, note that if MyArr were a multi-dimensional array, the loop would traverse over all elements of all dimensions.

You could traverse this array with a Do loop using a soft-coded upper bound:

With the above method, the argument you pass to GetUpperBound specifies which dimension to traverse.

And, you could also use For/Each to traverse the array:

The For/Each method is handy, but it does not explicitly provide access to the current index of the element fetched.

In Part 4, we’ll take a look at passing arrays as arguments.