what is a jagged array

for a start there are two types of arrays in c#
1) rectangular arrays
2) jagged arrays
rectangular arrays are of course rectangular arrays :-) wether single dimensional or multi dimensional all their elements length are equal
e.g

int[] arrSingle=new arrSingle[5];
int[,] arrTwoDimensional=new int[,] {{1,2,3},{1,2,3}}

jagged arrays are just arrays of arrays but when it comes to their shape their element length can vary

int[][] jaggedArray = new int[3][];
jaggedArray[0] = new int[] {1, 2, 3};
jaggedArray[1] = new int[] {1, 2, 3, 4, 5, 6};
jaggedArray[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};

thats all you need to know

0 comments:

Post a Comment