JUAN
JUAN

Reputation: 523

array used the same memory space?

i have an array in the main program like this: (i am using C# to program in asp.net)

double[][] example= new double[][];

for this example lets imagine is an array of 10*2.

so next thing i will do is send this array to another function like this:

usedarray(example);
public double[][] usedarray(double[][]examplearray)
{

}

i know that a double array in each space has only 64 bit floating point number, so the array will have a 1280 bits for this example used memory, but when is send to the function it used the same space of memory? or it use a complete new set of memory space?

Upvotes: 1

Views: 180

Answers (1)

Servy
Servy

Reputation: 203819

Arrays are reference types, not value types. That means that the variable, examplearray doesn't actually contain 1280 bits of data, it just contains a reference (sometimes also referred to as a pointer) to the actual data, which is stored elsewhere (for the purposes of this post, it doesn't matter where "elsewhere" actually is). Passing that variable to a method, as you have done there, is only copying that reference (which is 32 or 64 bits, depending on the system), not the underlying 1280 bits of data.

Upvotes: 2

Related Questions