For Loop

suggest change

A For Loop is great for doing things a certain amount of time. It’s like a While Loop but the increment is included with the condition.

A For Loop is set up like this:

for (Initialization; Condition; Increment)
{
    // Code
}
Initialization - Makes a new local variable that can only be used in the loop.

Condition - The loop only runs when the condition is true.

Increment - How the variable changes every time the loop runs.

An example:

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

Output:

0 1 2 3 4

You can also leave out spaces in the For Loop, but you have to have all semicolons for it to function.

int input = Console.ReadLine();    

for ( ; input < 10; input + 2)
{
    Console.WriteLine(input);
}

Output for 3:

3 5 7 9 11

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Looping:
* For Loop
* break

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script