22.jagged array in c#
/*
Jagged array is a array of arrays such that member arrays can be of different sizes. In other words, the length of each array index can differ. The elements of Jagged Array are reference types and initialized to null by default.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace jaggedarrayexample
{
class Program
{
static void Main(string[] args)
{
string[][] student = new string[2][]{
new string[]{"A","B","C","D"},
new string[]{"E","F"}
};
for (int i = 0; i < 2; i++)
{
foreach (string nm in student[i])
{
Console.Write(nm + " ");
}
Console.WriteLine();
}
Console.Read();
}
}
}
Comments
Post a Comment