概述
如下C#代码:
int sum=0;
for(int i=1;i<101;i++)
{
if(i%2!=0)
{
continue;
}
sum+=i;
}
可以考虑用以下VB.NET代码实现:
Dim sum As Integer, i As Integer
For i = 1 To 100
If (i Mod 2 = 0) Then
sum = sum + i
End If
Next
Dim sum As Integer, i As Integer
For i = 1 To 100
If (i Mod 2 <> 0) Then
GoTo continue
End If
sum = sum + i
continue:
Next
另外在VB.NET 2005,已经实现了continue语法
For i As Integer = 0 To 100
' If i = 50 skip Console.Writeline statement
If i = 50 Then Continue For
Console.WriteLine(i.ToString)
Next
' Do While using Continue statement.
Dim ii As Integer = 1
Do While ii < 100
ii += 1
' If i = 50 skip Console.Writeline statement
If ii = 50 Then Continue Do
Console.WriteLine(ii.ToString)
Loop
' While using Continue statement.
Dim iii As Integer = 1
While iii < 100
iii += 1
' If i = 50 skip Console.Writeline statement
If iii = 50 Then Continue While
Console.WriteLine(iii.ToString)
End While
转自:http://www.lob.cn/jq/kfjq/528.shtml
具体介绍查看:
http://msmvps.com/mcintyre/archive/2004/06/18/8449.aspx
转载于:https://www.cnblogs.com/wwlearn/archive/2008/11/21/1338128.html
最后
以上就是健康白昼为你收集整理的VB.Net实现类似C#中continue的功能的全部内容,希望文章能够帮你解决VB.Net实现类似C#中continue的功能所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复