Regarding your comment to the question: you're saying that one can do "some complex stuff" with the for
-loop you're trying to discover. I have to say: you seem to be on the wrong track. The for
-loop has always the same simple structure:
for (Type variable = startvalue; condition; action)
{
// Do stuff
}
The "complex" stuff is to sometimes find out what condition is or what action to take. condition
may be anything that evaluates to boolean
and action
may be anything too.
So the "complex" stuff has nothing to do with the structure of the for
-loop itself. You could also write the following:
for (int i = 0; DateTime.Now < new DateTime(2009, 12, 31); i++)
{
Console.WriteLine("I've iterated {0} times before 31st December 2009!", i);
}
The condition does not even consider the i
variable, but still it is a valid for
-loop.