I’m walking through a Forloop 100’000 times. (that number can be diversified)
Every 1000th time I want do something specially, what I don’t do in the other walkthroughs.
Something like that:
for (int i = 0; i < 100000; i++)
{
doTasks(); //Normal
if(i == 1000 || i == 2000 || i == 3000 || i == 4000 ) //and so on...
{
doSomethingElse(); //Special, For every 1000th walkthrough
}
}
What would be the most efficient way to accomplish that task?
Try with a modulo operator. Not sure about the C# syntax, but something like: