Copy one 2D array to another 2D array

后端 未结 3 781
庸人自扰
庸人自扰 2020-12-09 16:44

I used this code to copy one 2D array to another 2D array:

Array.Copy(teamPerformance, 0,tempPerformance,0, teamPerformance.Length);

Howeve

3条回答
  •  一个人的身影
    2020-12-09 17:11

    You need Clone()

    double[,] arr = 
    {
       {1, 2},
       {3, 4}
    };
    double[,] copy = arr.Clone() as double[,];
    copy[0, 0] = 2;
    //it really copies the values, not a shallow copy, 
    //after:
    //arr[0,0] will be 1
    //copy[0,0] will be 2
    

提交回复
热议问题