I am testing how to get multiple data returned from a function. I was trying to use a List of int[]
. To do this I have a function that returns a List<int[]>
, which is shown below:
private List<int[]> Test()
{
List<int[]> testlist = new List<int[]>();
int[] record = new int[3];
record[0] = 1;
record[1] = 2;
record[2] = 3;
testlist.Add(record);
record[0] = 11;
record[1] = 12;
record[2] = 13;
testlist.Add(record);
return testlist;
}
When i check the contents of the list, I see that it contains 2 records but they both contain the last records of the int[]
. Which means that instead of
list[0] = {1,2,3}
list[1] = {11,12,13}
I get
list[0] = {11,12,13}
list[1] = {11,12,13}
I was wondering why this is happening.