title: C# Index and length must refer to location within string
body: <p>On running below program error is shown
  **</p>
  
  <blockquote>
    <p>Unhandled Exception : systemArgumentOutofRange:Index and length must
    refere to location within string.</p>
  </blockquote>
  
  <p>**</p>
  
  <pre><code>string input = "OneTwoThree sdfhguiosdrb asdhfuiaserthf aseiryaseuigraweui";           
  
  int size = input.Length;
  if (input.Length &gt; 30)
  {
      msg1 = input.Substring(0, 30);
      msg2 = input.Substring(msg1.Length, size);
      Console.WriteLine("Message: {0}", msg1);
      Console.WriteLine("\nMessage: {0}", msg2);
  }
  else
      Console.WriteLine(input);
  </code></pre>
  
  <p>Please help what I am doing wrong.</p>