Returning one dimension of a two-dimensional array

Hi All,

I’d like a foreach loop to loop through each entry inside a certain dimension of a two-dimensional array. I’m using a multi-dimensional, non-jagged C# array of GameObjects, like this:

foreach(GameObject face in faceArray[cubeNumber, *])

What’s the proper syntax for this?

Doing a foreach on a multidimensional array flattens it, so that wouldn’t work. However, if you have an array of an array, then you could do it.

However, I would probably do something like this for columns:

for (int i = 0; i < yLength; i++)
{
  // Do something with faceArray[cubeNumber, i];
}

For rows:

for (int i = 0; i < xLength; i++)
{
  // Do something with faceArray[i, cubeNumber];
}