|
-
June 8th, 2011, 05:54 PM
#1
out of range exception (except it isn't)
i'm using visual studio 2010 and i'm getting the error:
Unhandled Exception: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Occuring on a call to Substring(int,int);
here's my code (it's testing so there are magic numbers):
Code:
//No out of bounds exceptions
int temp = end - 150;
if (temp > 0)
{
source = source.Substring(temp, end);
}
source is approximately 32000 characters in length and end is looking at index ~18000 (and obviously temp is index less 150). I have tested it with the parameters such as:
Code:
source = source.Substring(0,end);
and there is no problem, but i have no idea why it would not work with temp. i have tried using a dummy string variable, but as i figured it has nothing to do with the assignment source = source.Substring...
No idea how this can be the case >_>
EDIT: nevermind, i misremembered Substring (second parameter is the number of characters you want to copy).
Last edited by jokul; June 8th, 2011 at 07:04 PM.
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
|