Here are two examples :
I have an array with 3 items : Universe, planet and Continent I want to use a foreach loop like this :
foreach(var universe in Universe)
{
foreach(var planet in Planet)
{
foreach(var continent in Continent)
{
// here comes my code
} } }
In this case the array contains 3 elements and therefore I need 3 foreach statements.
Now lets say that I add 2 extra items to the array (Country and State) There would have to be 5 foreach loops.
But what if the array contains 600 items : then I would need to write 600 foreach statements...
So how can this be programatically solved?
- Dynamic code addition?
- Recursive codes (I have no experience with them)
- ...