System.ArgumentOutOfRangeException in my word search program
<p>I don't understand what's going wrong here. Could someone explain please?</p>

<pre><code>using System;

public class Test
{
        public static void Main()
        {
                int bobo = 0;
                string result = "";
                string bob;
                string search = Console.ReadLine();
                string words = Console.ReadLine();
                string first = words.Substring(0,1);
                string second = words.Substring(1,2);
                string third = words.Substring(2,3);
                for(int i = 0;i&lt;searchc.Length;i++)
                {
                        bobo++;
                        bob = search.Substring(bobo,bobo+2);    
                        if(bob == first)
                        {
                                result += bob.ToUpper();
                        }
                }

                Console.WriteLine(result);
        }
}
</code></pre>

<p>The error message I see is:</p>

<pre><code>Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length &gt; this.length
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in &lt;filename unknown&gt;:0 
  at Test.Main () [0x00000] in &lt;filename unknown&gt;:0 
</code></pre>
