[求助]为什么返回一个二维数组时,对数组所做的修改不保留?
for (int i = 0; i < city_num; i++)for (int j = 0; j < popsize; j++)
{
int a = 0, b = 0;
System.Random r = new Random();
a = r.Next(0, city_num-1);
b = r.Next(0, city_num - 1);
int temp;
temp = pop[j, a];
pop[j, a] = pop[j, b];
pop[j, b] = temp;
}
return pop;
我用如上代码试图打乱原二维数组的元素顺序,调试时,在return pop前显示的二维数组顺序已经被打乱了,可是return出来的pop数组却还是原来的顺序,这是为什么?怎么解决?谢谢!