How to make a shallow copy of an array?

后端 未结 9 736
梦如初夏
梦如初夏 2020-11-27 22:21

I pass a two-dimensional array as a property to my user control. There I store this values in another two-dimensional array:

int[,] originalValues = this.Met         


        
9条回答
  •  余生分开走
    2020-11-27 22:52

    If the object you are copying is an array, then you can use:

    Array.Copy(sourceArray, destinationArray, sourceArray.Count)
    

    This will give you a separate copy of the original array into your destination array.

提交回复
热议问题