Just a quick note here on foreach loops. Not sure if you knew this but foreach loops can be used to iterate over multidimensional arrays.

Imagine you have:

int[,,] myInts = {{ { 0, 1, 2 }, { 3, 4, 5 } }, { { 0, 1, 2 }, { 3, 4, 5 } }};

you can iterate over the whole 3D array here in a single foreach:

foreach (int i in myInts)
{
    Debug.Write(i.ToString());
}

The resulting output is: 012345012345.

This will only work for multidimensional arrays. For jagged arrays you’ll have to do multiple foreach loops.

int[][] myInts = new int[][]{ new int[]{ 0, 1, 2 }, new int[]{ 3, 4, 5, 6 } };
foreach(int[] childArray in myInts)
{
    foreach(int child in childArray)
    {
        Debug.Write(child.ToString());
    }
}

Later,
Brian

Leave a Reply

Your email address will not be published. Required fields are marked *

FormatException

928 East Plymouth Drive Asbury Park, NJ 07712