Summing a jagged int array in C#
<p>As done here: <a href="https://stackoverflow.com/questions/38267553/c-two-dimensional-int-array-sum-off-all-elements">C # Two-dimensional int array,Sum off all elements</a>, but this time with jagged arrays. Getting:</p>

<blockquote>
  <p>System.IndexOutOfRangeException.</p>
</blockquote>

<p>I am a beginner asking for help. This is my code:</p>

<pre><code>public static int Sum(int[][] arr) 
{
    int total = 0;
    for (int i = 0; i &lt; arr.GetLength(0); i++)
    {
         for (int j = 0; j &lt; arr.GetLength(1); j++) 
         { 
              total += arr[i][j];
         }
    } 
    return total; 
}

static void Main(string[] args)
{
     int[][] arr = new int[][] 
     {
          new int [] {1},
          new int [] {1,3,-5},
     };
     int total = Sum(arr);
     Console.WriteLine();
     Console.ReadKey();    
}
</code></pre>