![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0
![]() |
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}},
{{2, 7, 3, 6}, {5, 1, 9, 0}},
{{0, 4, 9, 7}, {3, 9, 8, 5}}};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. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Newbie
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#6 | |
|
Programmer
Join Date: Dec 2005
Posts: 53
Rep Power: 3
![]() |
Quote:
|
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0
![]() |
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 ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|