Foreach loop
double[] pArray= new double[50];
foreach (int i in problem7Array)
{
pArray[i]= i * 1.13;
}
how come i never get's incremented and stays at 0 for all 50 iterations?
Steve
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
will he14 pointsPosted Feb 15, 2006, 6:11 AM EST
Binu Subi68 pointsPosted Feb 15, 2006, 11:15 AM EST
when you are using foreach,
int i represents an item in the collection
further more if it is a value type (like in your case int) it is read only
foreach basically repeats a group of statements for each value in a collection
Cheers!