While Statement
The while statement is continously executed a block of code, until the condition is not true anymore. The while statement is also called a loop since it executes repeatedly one after the other until the condition is not met anymore.
while (expression) {
statement/s
}
A proper example of a while loop is the following:
int counter = 1;
string result = "";
while (counter < 11)
{
result += "Count is: " + counter;
counter++;
}
Explanation: While the counter is less than 11, therefore equal to ten, add to the result variable "Counter is : " and the counter amount. The value of counter changes with "counter++" which means: increment the value in counter by one.