A for loop is useful when you have an indication or determination, in advance, of how many times you want a loop to run. As an example, if you need to perform a process for each day of the week, you know you want 7 loops.
A foreach loop is when you want to repeat a process for all pieces of a collection or array, but it is not important specifically how many times the loop runs. As an example, you are formatting a list of favorite books for users. Every user may have a different number of books, or none, and we don't really care how many it is, we just want the loop to act on all of them.
For Loop
In case of for the variable of the loop is always be int only.
The For Loop executes the statement or block of statements repeatedly until specified expression evaluates to false.
There is need to specify the loop bounds(Minimum, Maximum).
Example
using sytem;
class class1
{
static void Main()
{
int j=0;
for(int i=0; i<=10;i++)
{
j=j+1;
}
Console.ReadLine();
}

Join the conversation! Your thoughts help the community grow.