I've done this before, alas I do not have the code here with me.
Build a utility method that calls itself recursively, tests whether an array element is an array itself, if it is not (and so a value) add it to a List, otherwise pass the sub/child array to the recursive method.
Hint, use Array object as the parameter for this method, rather than a defined int[,][]
array, thus any form of crazy int[,][][][,,,][][,]
can be passed and will still work.
And for your problem, you would have to detect at what level you wish to stop transforming from jagged arrays to values, and then returning those jagged arrays, in a simplified array.
I will post my code later, it may help you.
public static int Count(Array pValues)
{
int count = 0;
foreach(object value in pValues)
{
if(value.GetType().IsArray)
{
count += Count((Array) value);
}
else
{
count ++;
}
}
return count;
}