what is this error"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
Help me
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Posted Aug 19, 2013, 8:46 PM EDT
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.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 8:49 PM EDT
Please share your code.
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 19, 2013, 8:53 PM EDT
Share your code. so we can able to solve your problem.
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 19, 2013, 9:04 PM EDT
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.