title: String.Substring(...) Method Gives Exception
body: <p>I want to keep a string to another string strTotal from a richtextbox. then i want to split it into two SubString like firstPart and secondPart by a middle index say: midIndex.</p>
  
  <p>Then I want to change some value in firsthalf and join with secondhalf. And finally show it to the richTextBox. </p>
  
  <p>For this i used this code:</p>
  
  <p>For my Last debug:</p>
  
  <p>rtxtQueryPan.Text.Length = 53;
  midIndex = 45;</p>
  
  <pre><code> //string Totalqueryy = rtxtQueryPan.Text;
   string firstHalf = rtxtQueryPan.Text.Substring(0, midIndex-2); 
   string secondHalf = rtxtQueryPan.Text.Substring((midIndex- 1), (rtxtQueryPan.Text.Length - 1)); // THIS LINE SHOWS ERROR
  
   string duplicateFirstHalf = firstHalf;
   firstHalf += " " + clColumnNames.Text + ",";
   rtxtQueryPan.Text = firstHalf+secondHalf;
  </code></pre>
  
  <p>In the 3rd Line of the code says: </p>
  
  <p><strong>Index and length must refer to a location within the string.
  Parameter name: length</strong></p>
  
  <p>I have checked the length, midIndexvalue etc. But found no clue.</p>