gpt4 book ai didi

VB.NET - 如何在 For Each 循环中移动到下一个项目?

转载 作者:行者123 更新时间:2023-12-03 05:01:28 25 4
gpt4 key购买 nike

是否有类似 Exit For 的语句,只不过不是退出循环,而是移至下一项。

例如:

For Each I As Item In Items

If I = x Then
' Move to next item
End If

' Do something

Next

我知道可以简单地在 If 语句中添加一个 Else ,这样它的内容如下:

For Each I As Item In Items

If I = x Then
' Move to next item
Else
' Do something
End If

Next

只是想知道是否有办法跳转到 Items 列表中的下一个项目。我确信大多数人会正确地问为什么不只使用 Else 语句,但对我来说,包装“Do Something”代码似乎不太可读。特别是当代码很多时。

最佳答案

For Each I As Item In Items
If I = x Then Continue For

' Do something
Next

关于VB.NET - 如何在 For Each 循环中移动到下一个项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/829689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com