Single Dimensional arrays

S

Sim

Hi,

I come from a C background and I heard that in C# single dimensional
arrays are stored in a tree structure internally? Is that true? I know
that's true for jagged arrays but I'm not sure about single dimensional
arrays. Could someone clear this out for me because it's important I
know all the aspects on arrays before I implement what I need to. Thanks

Sim
 
M

Mattias Sjögren

I come from a C background and I heard that in C# single dimensional
arrays are stored in a tree structure internally? Is that true?

No, the items in a single dimensional array are stored sequentially in
memory, like an array in C.



Mattias
 
B

Bruno Jouhier [MVP]

That's just wrong. C# arrays are contiguous arrays internally. Where did you
hear this from?

Bruno.
 
J

Jon Skeet

Sim said:
What about jagged? They're in a tree, right?

Well, it depends what you mean by a tree. A jagged array is just an
array of arrays. Each array itself is stored sequentially in memory,
but the contents of each element is a reference to another array (or
null).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top