xxxxxxxxxx
//this loop will repeat 4 times
for(int i=0; i<4; i++)
{
//do something
}
xxxxxxxxxx
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i);
}
______________OUTPUT____________
0
1
2
3
4
xxxxxxxxxx
//int i = 0 -- Making variable i
//i <=10 -- Making a condition for the loop to keep going
//i++ -- Increasing i by 1
for(int i = 0; i <= 10; i++)
{
Console.Write(i+1);
}
/*
Output:
12345678910
*/
xxxxxxxxxx
using System;
namespace Loop
{
class ForLoop
{
public static void Main(string[] args)
{
for (int i=0; i<=10; i++)
{
Console.WriteLine("C# For Loop: Iteration {0}", i);
}
}
}
}
xxxxxxxxxx
for(i = 2; i < 100; i*=2)
{
Console.Write(i + " ");
}
Console.Readkey();
xxxxxxxxxx
for (int row = 1; row < 11; row++)
{
Console.WriteLine($"The row is {row}");
}