The upperbound of the array is 2
3 elements are contained within the array
I suggest as a starting value of 0 and an ending value of 2
The code in figure 4 produces an IndexOutOfRangeException because the loop is trying to access an index that is beyond the upperbound of the array, in this case the upperbound of the array is 2 and the loops ending condition is 3, the exception is thrown when the intLoopCounter reaches 3 because it should really be 2
The value that is displayed in the message box when the loop is in it’s second iteration is string 2
No comments:
Post a Comment