Simple question: What is best, method 1 or method 2?
Is method 2 faster/better:
List<int> data = Enumerable.Range(0, 10000000).ToList();
int j = 0;
// Method 1
while (j < data.Count)
{
// do something
j++;
}
j = 0;
// Method 2
while (j++ < data.Count)
{
// do something
}
or would a simple for-loop still be better?
Update: according to the comments, a subquestion: Should while-loops be avoided or should for-loops be avoided and replaced with these while-loops?