First of all, the difference between foreach and for, foreach is for the object traversal, do not need to define the number of cycles, but there is a disadvantage, the foreach traversal is read-only data, can not be in a Foreach object additions and deletions, and the for loop can be. Your code to change to a while loop is as follows:
| The code is as follows |
Copy Code |
|
int I=0;while (i<ds. table["Userreg"]. Rows.Count) {i++;} |
Cases
| The code is as follows |
Copy Code |
|
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Interrupt Loop
{
Class Program
{
static void Main (string[] args)
{
100 or less, seven.
int i = 0;
while (I < 100)
{
i++;
if (i%7==0 | | i%10==7| | I/10==7)
{
Continue
}
Console.WriteLine ("{0}", i);
}
Console.readkey ();
}
}
} |
the difference between the Return,continue,break in the while.
Return: Exit main function
Continue: Directly to the next round cycle
Break: Jump right out of the current loop