A "index was out of range" Error happens if you try to access an element in a array which not exist. In C# the first element has the index 0 and the last element has n-1. So the error mostly happens if the code acces the n element as last.
You should check the numbers of elements in a list or array with count or lenght. The last element is then count-1 or lenght-1.
|