using System;
//csc array_jagged.cs

namespace array_jagged
{
class ArrayJagged
{
public static void process()
{
// Declare the stray of two elements:
string[][] str = new string[2][];

// Initialize the elements:
str[0] = new string[5] {"a", "b", "c", "d" , "e" };
str[1] = new string[4] {"ab", "bc", "cd", "de" };
// str[2] = new string[4] {"ab", "bc", "cd", "de" };

// Display the stray elements:
for (int i = 0; i < str.Length; i++)
{
//Console.Write("Element({1}): ", i);

for (int j = 0; j < str[i].Length; j++)
{
Console.Write("{0}{1}", str[i][j], j == (str[i].Length - 1) ? "" : " ");
}
Console.WriteLine();
}
}
}
class test
{
static void Main()
{
ArrayJagged.process();
Console.ReadLine();
}
}
}

I could not increase another row with the same type of nested for loops. I took alternate hard coded apprach to understand the jagged array.


using System;
//csc array_jagged_2.cs

namespace array_jagged
{
class ArrayJagged
{
public static void process()
{
// Declare the stray of two elements:
string[][] str = new string[3][];
// Initialize the elements:
str[0] = new string[5] {"a", "b", "c", "d" , "e" };
str[1] = new string[4] {"ab", "bc", "cd", "de" };
str[2] = new string[4] {"abc","bcc", "cde", "def" };
// Display the stray elements:
int i = 0;
for(i = 0; i < 5 ; i++) { Console.Write( str[0][i] + '\t');}
Console.WriteLine();
for(i= 0; i < 4 ; i++) { Console.Write( str[1][i] + '\t');}
Console.WriteLine();
for(i= 0; i < 4 ; i++) { Console.Write( str[2][i] + '\t');}
}
}
class test
{
static void Main()
{
ArrayJagged.process();
Console.ReadLine();
}
}

}