更新时间:2023-10-30 14:44:04
在这些情况下,尝试没有任何意义:你没有使用对象的集合,因此没有foreach循环的基础 - 这些仅在您通过实现IEnumerable或IEnumerable< T>的对象集合进行迭代时起作用。接口。Int32
不这样做,所以你不能使用foreach
替换for
循环。
In those cases, it makes no sense to try: you aren't using a collection of objects, so there is no base for a foreach loop - these only work when you are iterating though a collection of objects that implements the IEnumerable or IEnumerable<T> interface.Int32
doesn't do that, so you can't use aforeach
to replace yourfor
loops.