C# For Loop
C# For Loop
The for loop in C# is used to repeat a block of code a specific number of times. It is best when you know in advance how many iterations are required.
Basic for Loop Syntax
Simple Example
Output:
For Loop Flow
Initialize variable
Check condition
Execute code
Update variable
Repeat until condition is false
Loop with Different Increment
Reverse for Loop
Multiple Variables in for Loop
break in for Loop
continue in for Loop
Nested for Loop
Common Uses
✔ Printing patterns
✔ Iterating arrays
✔ Counting loops
✔ Mathematical tables
Summary
✔ for loop is used for fixed iterations
✔ Contains initialization, condition, update
✔ Supports break and continue
✔ Can be nested
