Igl*_*ija 1 c# variables loops
我怎样才能创建一个循环,它会在我想要的时候重新开始,让我们说我想在我的变量时重新开始循环
VarOfLoop++ ;
Run Code Online (Sandbox Code Playgroud)
得到1,循环将重新开始; 我怎么能结束这个循环呢?就像每个人一样,我们使用"休息";
如果使用for循环而不是foreach循环,则可以控制迭代器的值.像这样的东西:
for (var i = 0; i < someUpperLimit, i++)
{
// do something, iterating over some values with "i" as the index
if (someCondition)
i = -1; // re-start the loop (i will increment to 0 on the next iteration)
else if (someOtherCondition)
break; // exit the loop
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123 次 |
| 最近记录: |