繁体   English   中英

c# 用于循环中的每个进度循环

[英]c# for each progress loop within the loop

我有一种情况,我正在循环使用记录中的每条记录的 ac# 网页数据库记录集。

在该循环中,我还想执行另一个 do while 循环,以便可以将记录组合​​在一起。

是否有可能从循环内增加 for next 循环的迭代......很难解释,但像这样

 foreach (var records in records){

 do{
   <p>@records.NAME</p>
   INCREASE THE FOREACH LOOP ITERATION HERE
   currentName = records.NAME //this is now the next name in the recordset
 }while(currentName!=records.NAME)

 }

谢谢罗尔夫

这种方法最好做一个for循环

for (int index = 0; index < records.Count - 1; index++){

do{
   <p>@((records)records.Item(index)).NAME</p>
   index++;
   If(index < records.Count) {
      currentName = ((records)records.Item(index)).NAME; //this is now the next name in the recordset
   Else{
      Break;//Breaks out of the while loop because you are done with the for loop }
   }
}while(currentName!=((records)records.Item(index)).NAME)

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM