|
-
Oct 19th, 2011, 10:50 PM
#1
Thread Starter
Member
Index out of bound error when I know its not
I am trying to run this loop
Code:
int y = 0;
char[] tempmess = new char[] { };
for (int a = 56; a < SMS.Length; a++ )
{
tempmess[y] = SMS[a];
y++;
}
and I keep getting an index out of bounds exception when I know its not. SMS which is a char array has a length of 76. if I manually put in the number it works but if I try and loop it crashes long before it hits the end.
EDIT: its an IndexOutOfRange Exception
-
Oct 20th, 2011, 12:15 AM
#2
Re: Index out of bound error when I know its not
Which line is highlighted wit the error?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 20th, 2011, 12:41 AM
#3
Re: Index out of bound error when I know its not
What is the value of a and y when this happens?
-tg
-
Oct 20th, 2011, 01:36 AM
#4
Re: Index out of bound error when I know its not
Hmm, perhaps if tempmess[] was defined to have more than 0 elements...
-
Oct 24th, 2011, 10:23 AM
#5
New Member
Re: Index out of bound error when I know its not
Couldn't you use something like this?
Code:
char[] subSMS = SMS.ToString().Substring(56).ToCharArray();
I know that's probably really bad coding and perhaps inefficient but I'm kind of new with this sort of thing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|