I am trying to be able to run through a jagged array but the array depth is not constant. I am looking for a clean way to go through each object in the array. right now I have a simple switch case that can handle the different levels by getting its Rank as an int for the case.
but sometimes the array is 2 levels deep and sometimes it 5 levels deep. I would like to not have to write a case for each depth level.
for example, I have a object named myObj, some times it is myObj[] or myObj[][] or myObj[][][][];
using either foreach or IEnumerator only traverses the first dimension of the array
Your answer is recursion. I don't think this works. It would work if you had a class with child collections.