Index was outside the bounds of the array
<p>Friends</p>

<p>I have got an error which tells "Index was outside the bounds of the array"  I dont know y it was happening since after completeting the for loop  and entering the loop fresh again it was showing the variable value when exited from the loop before. </p>

<pre><code>        int[,] arrScr = new int[lstTest.Count, cnt2 + 3];
        string[,] arrName = new string[lstTest.Count, cnt2 + 3];
        int p;

        for (i = 0; i &lt; lstTest.Count; i++)
        {
            using (DataTableReader dtr3 = ds.Tables["scord_mark_table" + (i + 1).ToString()].CreateDataReader())
            {
                p = 0;
                while (dtr3.Read())
                {
                    arrName[i, 2 + p] = dtr3[15].ToString();
                    for (int k = 2; k &lt; 12; k++)
                    {
                        arrScr[i, 2 + p] += Convert.ToInt32(dtr3[k].ToString());
                    }
                    p++;
                }
            }
</code></pre>

<p><img src="http://i.stack.imgur.com/Ruj6W.png" alt="enter image description here"></p>
