I still need help understanding what is happening here:
class ParamArrayWithReturn
{
public static void Main()
{
F(3, 2, 15);
}
public static int[][] F(int n, int m, int value)
{
int[][] x = new int[ n ][];
for (int i = 0; i < n; i++)
{
x[ i ] = new int[m];
for (int j = 0; j < m; j++)
x[ i ][j] = value;
}
return x;
}
}
I see that we are going to dimension array to 3 indexes. Then I see what happens after that is that we then create two internal array indexes inside those 3. I also see that in this case, we will end up having the value of 15 at each index.
I believe it will look something like this:
15, 15
15,15
15, 15
Now why would we return x here And what happens to it when it returns to the method call I am confused by that part of the example.

Returning an array
Mahmoud_Fayed
John Paul Cook
It's difficult to understand your example because of the smileys, but i think i can help.
The array is allocated on the managed heap, and the method returns a reference to the data.
When this reference is not saved after the call to F(), the data becomes orphaned and therefore a candidate for garbage collection.
Does that answer your question
Kamalkanth Nayak
Hello!
please see the other post, I replied your answer there!
Hope it'll help!
Best Regards,