Reputation: 25058
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....
Upvotes: 0
Views: 397
Reputation: 5836
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
Upvotes: 1