How to nested for loops for n times ?
Ex.
- int nLoop = 4;
-
- for (int i = 0; i <= 10; i++)
- {
- for (int j = 0; j <= 5; j++)
- {
- for (int k = 0; k <= 12; k++)
- {
- for (int l = 0; l <= 5; l++)
- {
- Console.WriteLine(i + " " + j + " " + k + " " + l);
- }
- }
- }
- }
So if nLoop is 2 then there would only be 2 for loops i and j
if nLoop is 3 then there would only be 3 for loops i, j and k.