2
Answers

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

Karthi Keyan

Karthi Keyan

7y
1.5k
1
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)