string[] text = new string[2]; 

When debugging, it throws the following error: "Unhandled type exception" System.ArgumentOutOfRangeException "in mscorlib.dll

Additional Information: Length cannot be less than zero. "

 int first = Page.IndexOf(leftText) + leftText.Length; int last = Page.IndexOf(RightText, first); string[] text = new string[2]; text[0] = Page.Substring(first, (last - first)); text[1] = Page.Remove(0, last); 
  • I can not understand why this appears .. - Nikolay
  • need more code ..... basically after all this design. for swearing is not on this line, is it? - Alexey Shimansky
  • oh, I will have to load a lot .. I'll try to pull out the most necessary - Nikolay
  • one
    Well, what did you want? Show the variable declaration and everyone should guess where you have a specific problem in the code? ...... or do you need to translate the message? then it will not give you anything - Alexey Shimansky
  • int first = Page.IndexOf(leftText) + leftText.Length; int last = Page.IndexOf(RightText, first); string[] text = new string[2]; text[0] = Page.Substring(first, (last - first)); text[1] = Page.Remove(0, last); - Nikolay

1 answer 1

IndexOf returns -1 if there is no entry. So it turns further negative length.

  • and precisely, by re-cracking the code, I found that by chance the wrong parameter is passed to the function! Thanks) - Nikolay