Click here to Skip to main content
13,765,270 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
i got "StartIndex cannot be less than zero.
Parameter name: startIndex" when i use "<%=text.Remove(text.LastIndexOf(','))%>" in my aspx code .as i think this is due to empty value.
Urgent help plz
Thanks
Posted 30-Jan-12 20:09pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

int backSlashIndex = text.IndexOf("\\");
domain = (backSlashIndex >= 0) ? text.Substring(0, backSlashIndex) : text;
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The error you got is pretty clear - You can not pass less than zero for an ZERO-BASED indexing scenarios.

And I think as no string ',' is found LastIndexOf is giving -1

http://msdn.microsoft.com/en-us/library/9ad138yc.aspx[^]

Try checking this -1 return and handle accordingly.
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.181114.1 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100