rlum

rlum

  • NA
  • 1
  • 0

Why is foreach loop increasing my variable?

Nov 3 2004 11:13 AM
Here is the code: // loop though and add the values to the found parameters int i = 0; foreach (SqlParameter parameter in datahelper.sqlParams) { parameter.Value = paramValues[i++]; } datahelper.sqlParams is an array of 3 SqlParameter objects paramValues is an array of 3 string values the loop is increasing the value of i before it even hits it causing the array to go out of index. thanks in advance.

Answers (1)