title: Why is this function crashing my program?
body: <p>I'm new in programming and this is my first project and I'm using C#. Basically I tryed to do a function that insert one more single quote in string that already have a single quote, but this is crashing my program and I don't know why.</p>
  <p>The function:</p>
  <pre><code>private string CheckSingleQuote(string txt)
  {
      for (int i = 0; i &lt; txt.Length; i++)
          if (txt[i] == '\'')
              txt = txt.Insert(i, &quot;'&quot;);
      return txt;
  }
  </code></pre>
  <p>When I click in a specific button, this function is called ten times to set the value of the strings.</p>