Karthi Keyan

Karthi Keyan

  • 920
  • 755
  • 229.1k

string.Substring(); Index and length must refer to location

Jun 5 2017 4:14 AM
Hi,
 
i got the error in below code. what i did wrong...
 
Error : Index and length must refer to a location within the string.\r\nParameter name: length
 
Code :
  
int l1 = elespt[0].Length - 50;
int l2 = elespt[0].Length - 1;
string val = elespt[0].ToString();
p1 = val.Substring(l1, l2);
 
 
elespt[0] is " this page, it means the vendor you purchased this e-book from did not deliver the correct file. Please contact ".
 
Thanks in Advance. 

Answers (2)