1
Answer

Why is foreach loop increasing my variable?

Ask a question
rlum

rlum

19y
1.7k
1
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)