title: Argument is out of range
body: <p>I have a variable, that got alot of content that I need to sort through.
  But using IndexOf and Substring, just gives me an error that ain't that much obvious.</p>
  
  <blockquote>
    <p>ArgumentOutOfRangeException: Argument is out of range.</p>
    
    <p>Parameter name: startIndex</p>
  </blockquote>
  
  <p>The error is happening on the "string lookThroughString = .." line.</p>
  
  <p>My code is simply trying to look through a string, find the correct content and then spit it out.</p>
  
  <pre><code>private string SCRIPT_CONTENT;
  
  public string GetVariable(string variable_name) {
      int length = 0;
      string lookThroughString = SCRIPT_CONTENT.Substring(SCRIPT_CONTENT.IndexOf(variable_name));
  
      foreach(char c in lookThroughString) {
          if(c.ToString() != ";") {
              length++;
          }
      }
      return SCRIPT_CONTENT.Substring(SCRIPT_CONTENT.IndexOf(variable_name + "::"), length);
  }
  </code></pre>
  
  <p>The "Script" / "Content" i'm looking through is:</p>
  
  <pre><code>spellName::Fireball;
  spellID::1;
  </code></pre>
  
  <p>I want this function, to return basicly from the start of the entered variable name (In this case 'SpellName') and until the first semicolon.</p>