C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-02-2009, 08:27 PM   #1
Registered User
 
Join Date: Sep 2008
Posts: 62
jagged arrays with multidimensional array

Jagged arrays, namely arrays of arrays is basically similar to a regular dimensional array, which is not hard to understand. But here within a jagged array, there is another array, which is kind of a bit vague to me.

here is a jagged array with a two dimensional array:


int [][,] jagged = new int [3][,];

// so there are three rows

|---------| // row 0;
|---------|

|---------| // row 1;
|---------|

|---------| // row 2;
|---------|

// When we assign jagged [0] a reference to a 4 x 2 array.

jagged [0] = int new [4,2];

// Does it mean that we assign four columns to the row 0?

|---------| |---------| |---------| |---------|
|---------| |---------| |---------| |---------|

// and within each row, there are two more rows?

|--0----1---| |--0----1---| |--0----1---| |--0----1---|
|------0----| |-------1----| |-----2-----| |------3-----|

// So when we assign value to jagged [0][1,0] = 10;
// Does it mean that we access to the second column, which is 1 of the row 0 and
// assign the value 10 to the second row of 1, which is above the column named 1
// 0 and 1, and we assign the 10 to 1, not 0?
kenryuakuma is offline   Reply With Quote
Old 11-07-2009, 01:16 AM   #2
Registered User
 
C_ntua's Avatar
 
Join Date: Jun 2008
Posts: 1,134
Code:
int [][,] jagged = new int [3][,];|
Means that you have an array of 2D arrays.

Code:
jagged [0] = int new [4,2];
So you assign on jagged[0] a new 4X2 array.

jagged[0] =
* *
* *
* *
* *

If you do
Code:
jagged [1] = int new [3,3];
jagged[1] =
* * *
* * *
* * *
C_ntua is offline   Reply With Quote
Old 11-07-2009, 07:07 AM   #3
Registered User
 
Join Date: Nov 2009
Posts: 1
I thing that: here is a jagged array with a two dimensional array:


int [][,] jagged = new int [3][,];
_______________
medical SEO | doctor website | medical practice marketing
doctorweb is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
allocation and reallocation of memory dynamically of an integer array zamir C++ Programming 16 05-29-2009 07:25 PM
Returning a multidimensional array from pointer function in Visual C++ yalcin C++ Programming 0 05-29-2009 05:48 AM
Class Template Trouble pliang C++ Programming 4 04-21-2005 04:15 AM
Multidimensional Array in a Structure Night_Blade C Programming 3 04-04-2005 08:14 PM
Type and nontype parameters w/overloading Mr_LJ C++ Programming 3 01-02-2004 01:01 AM


All times are GMT -6. The time now is 08:40 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22