且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为每个循环转换我的循环?

更新时间: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 a foreach to replace your for loops.