In VB. How to Implement the function similar to "continue" in C # In NET

Source: Internet
Author: User


The following C # code:
Int sum = 0;
For (int I = 1; I <101; I ++)
{
If (I % 2! = 0)
{
Continue;
}
Sum + = I;
}
You can consider using the following VB. NET code:
Dim sum As Integer, I As Integer
For 1 To 100
If (I Mod 2 = 0) Then
Sum = sum + I
End If
Next
Dim sum As Integer, I As Integer
For 1 To 100
If (I Mod 2 <> 0) Then
GoTo continue
End If
Sum = sum + I
Continue:
Next
In addition, in VB. NET 2005, The continue syntax has been implemented.
For I As Integer = 0 To 100
'If I = 50 skip Console. Writeline statement
If I = 50 Then Continue
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.