Possible Duplicates:
Is a variable named i unacceptable?
What is an ideal variable naming convention for loop variables?
Coming from a C background I’ve always used int i for generic loop variables. Of course in big nested loops or other complex things I may use a descriptive name but which one had you rather see?
int i;
for(i=0;i<Controls.Count;i++){
DoStuff(Controls[i]);
}
or
int index;
for(index=0;index<Controls.Count;index++){
DoStuff(Controls[index]);
}
In the current project I am working on there are both of these styles and index being replaced by ndx.
Which one is better? Is the i variable too generic? Also what about the other C style names? i, j, k Should all of these be replaced by actual descriptive variables?
i, however, is pretty standard in terms of the first loop, followed byjfor an inner loop andkfor an inner-inner loop, and so on.As with almost all naming rules, as long as it is standard within a project, and works well for all members thereof, then it’s fine.