![]() |
Trouble understanding simple concepts
I'm reading my C# book just about every day during lunchtime since that is the best time for me to understand new stuff.
I'm in the middle of learning about arrays and come up to these "jagged" arrays. I can understand the idea of arrays having non constant dimensions, but there's something I just don't get. :
int [,,] ia3d=new int [3,2,4] {{{8, 3, 4, 2}, {7, 4, 1, 2}},Can someone (or several of you) explain to me what is happening in this line in such a manner that I might understand it? Thanks. |
Why do you call them jagged arrays? It's quite regular. Consider a spreadsheet with 10 columns and 4 rows. That isn't even, but it's regular. Now consider a second sheet behind that one, with the same 10 columns and 4 rows. You now have a multidimensional array that is 2 x 4 x 10. Add rows. Add columns. Add row:n col m: on page 1 to row:n col:m on page 2. No biggie.
|
The book I'm reading called them jagged. That wasn't the problem I'm having.
[3,2,4] I'm seeing this a 3 high, 2 wide and 4 deep, right? Oh, SHIT!!! Nevermind. I'm an idiot. |
It does vary from language to language (Fortran is not the same as C). I don't know dink about C#, but it's probably the same as C/C++: [most significant]....[least significant]. Least significant signifying that the index is the most rapidly varying. A true array can be represented by a linear stretch of memory, regardless of dimensions.
|
Yeah. I was having a momentary lapse of reason. For some reason I was looking at that line and just not understanding what i was seeing. It was really frustrating because I knew that I knew it, but couldn't figure it out.
|
Quote:
|
It's not, I was saying I understood that concept. What I didn't understand was what I was looking at. Because my brain decided to attempt to divide by zero or something.
Just waiting for splinter to chime in ;) |
| All times are GMT -5. The time now is 8:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC