VB.NET - “继续”的替代方法适用于 Visual Studio 2003
我正在尝试跳到 for
循环中的下一个条目。
For Each i As Item In Items
If i = x Then
Continue For
End If
' Do something
Next
在 Visual Studio 2008 中,我可以使用“继续”。但在 VS Visual Studio 2003 中,这个不存在。我可以使用其他方法吗?
I'm trying to skip to the next entry in a for
loop.
For Each i As Item In Items
If i = x Then
Continue For
End If
' Do something
Next
In Visual Studio 2008, I can use "Continue For". But in VS Visual Studio 2003, this doesn't exist. Is there an alternative method I could use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果你的情况属实,你可以什么也不做。
Well you could simply do nothing if your condition is true.
从我读到的内容来看,VS2003 中不存在继续。但是您可以切换条件,以便仅在不满足条件时执行。
Continue, from what I've read, doesn't exist in VS2003. But you can switch your condition around so it only executes when the condition is not met.
它不是那么漂亮,但只是否定了“如果”。
It's not as pretty, but just negate the If.
您可以在循环体末尾使用带有标签的
GoTo
语句。You can use
GoTo
statement with label at the end of cycle body.根据您的代码,可能有点矫枉过正,但这里有一个替代方案:
Might be overkill depending on your code but here's an alternative: