returning values form jagged arrays
-
hi, i want to know how should i return values from jagged arrays public string[][] fync(Type webtype) { string[][] dimen= new string[3][]; dimen = getDetails(Type Webtype); //how should i collect values in dimen } public string[][] getDetails(Type webtype) { //suppose ss is jagged array of dimension ss[3][] //ie i have ss[0] = i have something // ss[1]= i have something else // ss[2]= i have some third item return ss; } I hope i am doing right help please Thanks JIny
-
hi, i want to know how should i return values from jagged arrays public string[][] fync(Type webtype) { string[][] dimen= new string[3][]; dimen = getDetails(Type Webtype); //how should i collect values in dimen } public string[][] getDetails(Type webtype) { //suppose ss is jagged array of dimension ss[3][] //ie i have ss[0] = i have something // ss[1]= i have something else // ss[2]= i have some third item return ss; } I hope i am doing right help please Thanks JIny
A jagged array is just an array of arrays. To create one you first create the main array, then create each sub-array:
string[][] ss;
ss = new string[3][];
ss[0] = new string[] { "Some", "strings" };
ss[1] = new string[] { "Some", "more", "strings" };
ss[2] = new string[2];
ss[2][0] = "Individual";
ss[2][1] = "strings";When you get the jagged array from the function, you shouldn't create an array first. That only means that you create an array that you will just throw away. Just declare the reference for the array:
string[][] dimen;
dimen = getDetails(webtype);--- b { font-weight: normal; }