首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何转到每个循环的下一个内部

如何转到每个循环的下一个内部
EN

Stack Overflow用户
提问于 2018-04-04 19:31:39
回答 1查看 171关注 0票数 0

最近,我需要修改在continue中使用多个for each案例的人的代码。新增的是for each内部的一个新的控制循环,这很快就打破了continue逻辑。是否有一种好的方法可以在这样的循环中获得下一个列表项而不重写所有的连续情况?

代码语言:javascript
运行
复制
// Additional control loops within the member function which cannot be 
// turned into functions due to native C++ data types.
{
    for each(KeyValuePair<String^,String^> kvp in ListOfItems) {
        do { // new condition testing code
           // a bunch of code that includes several chances to continue
        } while (!reachedCondition)
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-08 16:46:07

continuebreak进入内部最控制循环。我在for循环中使用了迭代器。因此,取决于您的ListOfItems是什么(即SortedListDictionary .)您可能可以迭代而不是continue

代码语言:javascript
运行
复制
int i=0;
Dictionary^ d = gcnew Dictionary<string, string>();

for (IEnumerator<KeyValuePair<string, string>>^ e =  d->GetEnumerator();i< d->Count;i++) {
    // do stuff
    e->MoveNext();
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49659011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档