This article describes the usage of while loop statements in C#. Share it for your reference. The specific implementation method is as follows:
In C#, while loop is a loop statement that we often use. The characteristic of while loop is that the loop does not jump out until the condition is zero. Of course, other functions can be used to jump out directly. It is necessary to make a more detailed analysis of the specific usage of while.
Let’s talk about the difference between Foreach and For first. Foreach traversal is traversal for objects and does not need to define the number of loops. However, there is a disadvantage. Foreach traversal takes read-only data, and objects cannot be added, deleted and modified in Foreach, and the For loop is fine. The code to change this to a while loop is as follows:
Examples are as follows:
using ;
using ;
using ;
namespace interrupt loop
{
class Program
{
static void Main(string[] args)
{
//Photo seven within 100
int i = 0;
while (i < 100)
{
i++;
if(i%7==0 || i%10==7||i/10==7)
{
continue;
}
("{0}",i);
}
();
}
}
}
Replenish:
The difference between return, continue, and break in while:
return: Exit main function
Continue: Directly perform the next cycle
break: Break out of the current loop directly
I hope this article will be helpful to everyone's C# programming.