我想运行这样的东西:
For a = 0 To 4
For b = a To 4
For c = b To 4
Console.WriteLine(a & b & c)
Next
Next
Next
但我需要彼此创建 n 个循环。所以我创建了这个方法:
'iFrom = 0; iTo = 4; Depth = 3(loop count);
Private Sub Iterate(ByVal iFrom As Integer, ByVal iTo As Integer, ByVal Depth As Integer)
For i = iFrom To iTo
If Depth - 1 > 0 Then Iterate(iFrom, iTo, Depth - 1)
'Do stuff here
Next
End Sub
从更高级别检索“i”值的最佳方法是什么?我应该将它们存储在数组中吗?还是有完全不同的方法来解决这个问题?