What are Jagged Arrays in C#?
A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ.
Example: A Jagged Array can be used is to create a table in which the lengths of the rows are not same. This Array is declared using square brackets ( [ ] ) to indicate each dimension.
The following code demonstrates the creation of a two-dimensional jagged array.
Class Jagged
{
public static void Main()
{
int [][] jagged=new int [3][];
jagged[0]=mew int[4]
jagged[1]=mew int[3]
jagged[2]=mew int[5]
int I;
‘Storing values in first array
for (I=0;I<4;i++)
jagged[0][I]=I;
‘Storing values in second array
for( I=0;I<3;I++)
jagged[1][I]=I;
‘Storing values in third array
for(I=0;I<5;I++)
jagged[2][I]=I;
‘Displaying values from first array
for (I=0;I<4;I++)
Console.WriteLine(jagged[0][I])
‘Displaying values from second array
for (I=0;I<3;I++)
Console.WriteLine(jagged[1][I])
‘Displaying values from third array
for(I=0;I<5;I++)
Console.WriteLine(jagged[2][I])
}
}
Search
Thursday, March 13, 2008
Jagged Arrays in C#
Labels:
Jagged Arrays in C#
Subscribe to:
Post Comments (Atom)
2 comments:
Warm welcome to blogger world.....Its really a great initiative, surely this portal would speak for ur technical capability.
Good Move daa and it will help others to develop their technical skills
Post a Comment