假设我有一个数组的名单
myArr
假设我要遍历FIRST列表(在我的数组中为元素0),然后停止。那可能吗?
现在我正在使用
for(int i = 0; i < myArr[0].count; i++)
{
do stuff
IF the array has gone to the next element in the ARRAY (Not the first LIST) Then break out of for loop
}
但它遍历整个数组(因此有7个列表)!我希望它仅遍历数组中的FIRST列表。有任何想法吗?
例如,如果我有
[0][0] = "cat"
[0][1] = "dog"
[1][0] = "seal"
我只想遍历直到我得到猫和狗(或直到遍历了第一个列表)为止,我才不关心密封和这种特殊情况下数组元素中包含的其余列表
您的代码实际上没有问题。这应该工作:
for(int i = 0; i < myArr[0].Count; i++) Console.WriteLine(myArr[0][i]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句