【发布时间】:2021-10-09 00:04:59
【问题描述】:
假设我有一个这样的数组:
string[] words = new string[3];
words[0] = "welcome";
words[1] = "hello";
words[2] = "hey";
我想克隆/复制它并修改它:
string[] new_words = words;
new_words[1] = "hi!";
问题在于它实际上也将words[1] = "hello"; 更改为words[1] = "hi!";,这不是我想要做的。
如何在不影响其来源的情况下复制/克隆数组并对其进行修改?非常感谢!
【问题讨论】: