what is this error"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Aug 20, 2013, 1:04 AM
hi,
this error due to wrong index pass to collect data from array or collection.
for example
int[] myarray = new int[5] { 1, 2, 3, 4, 5 };
int mydata = myarray[3];
int mywrongData = myarray[5];
int mywrongData1 = myarray[-5];
here my array size is 5 and i try to collect the data on position 6.so it give me error like Index out of bound.
hope this will help you.
Sanjeeb LenkaPosted Aug 20, 2013, 12:53 AM
Share your code. so we can able to solve your problem.
Iftikar HussainPosted Aug 20, 2013, 12:49 AM
Please share your code.
Regards,
Iftikar
Posted Aug 20, 2013, 12:46 AM
When you're doing index based operations like sub-string, but the index is number is -1 and greater than the string length then you'll get this kind of error.