Difference between the System.Array.CopyTo() and System.Array.Clone()

前端 未结 13 2171
攒了一身酷
攒了一身酷 2020-12-02 06:50

What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

13条回答
  •  难免孤独
    2020-12-02 07:29

    Both perform shallow copies as @PatrickDesjardins said (despite the many misled souls who think that CopyTo does a deep copy).

    However, CopyTo allows you to copy one array to a specified index in the destination array, giving it significantly more flexibility.

提交回复
热议问题