Loops statement
In vb.net & c# language Loops statement are differ.Code Loops statement of vb.net & c# language.____________________________________________________________________
VB.NET
Pre-test Loops: | |
While c <>End While | Do Until c = 10 |
Do While c <>Loop | For c = |
| |
Do | Do |
' Array or collection looping
Dim names As String() = {"Fred", "Sue", "Barney"}
For Each s As String In names
Console.WriteLine(s)
Next
' Breaking out of loops
Dim i As Integer = 0
While (True)
If (i = 5) Then Exit While
i += 1
End While
' Continue to next iteration
For i = 0 To 4
If i <>Continue For
Console.WriteLine(i) ' Only prints 4
Next
C#
Pre-test Loops:
// no "until" keyword
while (c <>for (c = 2; c <= 10; c += 2) Console.WriteLine(c);
Post-test
do
c++;
while (c < class="comment">// Array or collection looping
string[] names = {"Fred", "Sue", "Barney"};
foreach (string s in names)
Console.WriteLine(s);
// Breaking out of loops
int i = 0;
while (true) {
if (i == 5)
break;
i++;
}
// Continue to next iteration
for (i = 0; i <>continue;
Console.WriteLine(i); // Only prints 4
}
-------------------------------------------------------------------------------------------------
Note: This code applicable for both desktop and web application.
No comments:
Post a Comment