0

I have seen that declaring a bidimensional array as a jagged array is fine

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

but when doing some optimization at memory level in code, it is more convenient to use [,] as a definition of a matrix and use blocks of memory...

so can you explain if this is true? I guess the [,] takes a block of memory and the access of elements is faster rather than lookimg in several parts of memory in a jagged bidimensional array....

edgarmtze
  • 24,683
  • 80
  • 235
  • 386
  • I think you really want to read this http://stackoverflow.com/questions/597720/what-is-differences-between-multidimensional-array-and-array-of-arrays-in-c – m0s Feb 04 '12 at 08:45

1 Answers1

1

Yes, when an array is allocated as [,] , it is always given contiguous memory, so depending on what you want to do, it may be faster, convenient, etc

logicnp
  • 5,796
  • 1
  • 28
  • 32