Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error:-
C#
startIndex cannot be larger than length of string.
Parameter name: startIndex

so how can i solve this error?
Posted
Updated 5-Jun-12 3:03am
v2
Comments
Prasad_Kulkarni 5-Jun-12 8:41am    
Not clear, How could we come to know why it is giving such error?
Please provide some code snippet, and elaborate it.

in Substring you can pass only one parameter or 2parameter ,
in Substring With one parameter is: int index , its mean you have to pass the start number(that zero base value) of the string for new string and its an integer parameter .
Substring with two parameter have index and int length , that is the length of your new string!
you pass a index that is more than the string legth so this error is obvious , you have to change the index!
 
Share this answer
 
You are trying to do a SubString wherever the length of the substring you are trying to retrieve is larger than the string itself.
For more information, read about the Substring method here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900