|  | 
 
 发表于 2015-2-12 12:53:22
|
显示全部楼层 
| 本帖最后由 seabeam 于 2015-2-12 13:03 编辑 
 回复 7# macrohard
 
 复制一下LRM(2012)在12.7.3的原话吧:The number of loop variables shall not be greater than the number of dimensions of the array variable.
 关键点我红色高亮了。number of loop variables指循环变量的个数,例如:
 foreach (a),这里只有i一个loop variable,所以个数是1.再看另一个例子:
 foreach (b[i, j]),这里有两个loop variable,所以个数是2.
 
 举个例子,在使用foreach语句时,访问一维数组不能使用两个循环变量,LRM这句话只是想说:
 对于一个数组bit a[5],不能以
 foreach (a [i, j])
 的形式访问
 | 
 |