[英]c# for each progress loop within the loop
I have a situation where I am looping through ac# webpages database recordset using for each record in records.我有一种情况,我正在循环使用记录中的每条记录的 ac# 网页数据库记录集。
Within that loop I also want to perform another do while loop so that records can be grouped together.在该循环中,我还想执行另一个 do while 循环,以便可以将记录组合在一起。
Is it possible to increase the iteration of the for next loop from within the loop..hard to explain but something like this是否有可能从循环内增加 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)
}
Thanks Rolf谢谢罗尔夫
It is best to do a for loop for this type of method这种方法最好做一个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.