为了论证,我怎么能在VB中做到这一点?
foreach foo in bar
{
if (foo == null)
break;
if (foo = "sample")
continue;
// More code
//...
}
答案 0 :(得分:16)
- 编辑:
自从我回答以来你已经改变了你的问题,但我会在这里留下我的答案;我怀疑VB.NET程序员会告诉你如何实现这样的循环。我不想通过尝试来伤害我可怜的C#编译器的感受......
- 旧回复:
我相信有
Continue While
Continue For
和
Exit While
Exit For
答案 1 :(得分:2)
我认为VB.NET的例子可能在将来有所帮助:
Sub breakTest()
For i = 0 To 10
If (i = 5) Then
Exit For
End If
Console.WriteLine(i)
Next
For i = 0 To 10
If (i = 5) Then
Continue For
End If
Console.WriteLine(i)
Next
End Sub
休息的输出:
0
1
2
3
4
继续:
0
1
2
3
4
6
7
8
9
10