for

Unlike do..while, for evaluates the condition expression first and if true, executes the code block. The code block will not be executed once unless the condition is true. Similar to do..while, we can come out of the loop using the return, throw, goto, or continue statements.

Take a look at the following for statement's structure:

for (initializer; condition; iterator) 
{
body
}

The initializer, condition, and iterator are all optional. The body can be one statement or an entire code block:

for (int i = 0; i <= 5; i++)
{
Console.WriteLine("Number is :" + i);
}

//output
Number is :0
Number is :1
Number is :2
Number is :3
Number is :4
Number is :5
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.71.220