title: Need help with . string.substring(0, max.Length)
body: <p>ArgumentOutofBounds Exceptions is thrown all the times inside the ifs in the loop.</p>
  
  <p>In this code I am trying to send two strings between the symbol @2@3.</p>
  
  <p>string1+"@2@3"+string2</p>
  
  <p>Now I try to separate the strings from the symbols by the method substring, but an exception is being thrown over there......</p>
  
  <pre><code>public void seperatePMChattersNames(string TwoNames)
  {
      string nameOne="";
      string nameTwo="";
  
      Console.WriteLine(TwoNames);
      for (int i = 0; i &lt; TwoNames.Length; i++)
      {
          if (TwoNames[i] == '2' &amp;&amp; TwoNames[i-1] == '@')///ArgumentOutofRange Exception
          {
                  nameOne = TwoNames.Substring(0, i);
          }
          if (TwoNames[i] == '@' &amp;&amp; TwoNames[i+1] == '3')///ArgumentOutofRange Exception
          {           
              nameTwo = TwoNames.Substring(i+1, TwoNames.Length);               
          }
      }
  }
  </code></pre>
  
  <p>Why is it thrown and how to prevent it?</p>