【发布时间】:2018-04-04 19:31:39
【问题描述】:
我最近需要修改某人的代码,该代码在 for each 中使用了多个 continue 案例。添加的是for each 内部的新控制循环,它立即破坏了continue 逻辑。有没有一种好方法可以在这样的循环中获取下一个列表项,而无需重写所有的 continue 案例?
// 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)
}
}
【问题讨论】:
-
如果 C++/CLI 确实 支持命名循环,这会使问题变得微不足道。只需命名循环即可。
标签: foreach c++-cli next continue