I want to loop through the array which is the result of the array to the Cartesian power n. <https://en.wikipedia.org/wiki/Cartesian_product#n-ary_product>

This is what I want to achieve, just with n depth:

```
int[] array = new int[] { 5, -4, ... }
foreach(int a in array) {
    foreach(int b in array) {
        foreach(int c in array) {
           ...
           int[] NewArray = new int[] { a, b, c, ... }

```

In Python this is equivalent to:

```
from itertools import product
for (NewArray in product(array, repeat=n)):
    print(NewArray)

```

I do not know how I can implement this in C#. 

Any help would be highly appreciated. Thanks.