Jagged Array using VB.Net

Started by karthikn, Jul 23, 2008, 03:42 PM

Previous topic - Next topic

karthikn

Jagged Array, is an array of arrays in which the length of each array can differ. Example where this array can be used is to create a table in which the number of columns differ in each row. Say, if row1 has 3 columns, row2 has 3 columns then row3 can have 4 columns, row4 can have 5 columns and so on. The following code demonstrates jagged arrays.

[color=#e10000]Dim colors(2)() as String
'declaring an array of 3 arrays
colors(0)=New String(){"Red","blue","Green"}
initializing the first array to 3 members and setting values
colors(1)=New String(){"Yellow","Purple","Green","Violet"}
initializing the second array to 4 members and setting values
colors(2)=New String(){"Red","Black","White","Grey","Aqua"}[/color]


initializing the third array to 5 members and setting values