Reputation: 11057
For sake of argument, how could I do this in VB?
foreach foo in bar
{
if (foo == null)
break;
if (foo = "sample")
continue;
// More code
//...
}
Upvotes: 12
Views: 10299
Reputation: 4259
I thought a VB.NET example may help in the future:
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
The output for break:
0
1
2
3
4
And for continue:
0
1
2
3
4
6
7
8
9
10
Upvotes: 6
Reputation: 55072
-- Edit:
You've changed your question since I've answered, but I'll leave my answer here; I suspect a VB.NET programmer will show you how to implement such a loop. I don't want to hurt my poor C# compilers feelings by trying...
-- Old response:
I believe there is
Continue While
Continue For
and
Exit While
Exit For
Upvotes: 21