title: "Index and length must refer to a location within the string" error
body: <p>I am trying to extract the first 200 words of a string and sometimes I get the following error:</p>
  
  <pre><code>"Index and length must refer to a location within the string. Parameter name: length"
  </code></pre>
  
  <p>The code is:</p>
  
  <pre><code>int i = GetIndex(fullarticle, 200);
  string result = fullarticle.Substring(0, i);
  </code></pre>
  
  <p>How do I fix this?</p>