Why is foreach loop increasing my variable?
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.