我的C#应用程序中有一些与List有关的奇怪问题。这可能是分配错误或我的操作不正确(我是普通的C#开发人员)。 让我举个接近我的例子:
List<String[]> MyPrimaryList = new List<String[]>();
List<String[]> MySecondaryList = new List<String[]>();
String[] array;
String arrayList = "one,two,three,four,five";
array = arrayList.Split(',');
MyPrimaryList.Add(array);
MySecondaryList.Add(array);
MyPrimaryList[0][0] += "half";
所以我希望第一个数组中第一个值在MyPrimaryList中为"onehalf",而在MySecondaryList中为"one"。
但我的问题/难题是两个列表都使用"onehalf"作为它们的第一个值更新。你有什么好的解释吗? :)
谢谢!!
array
,你没有在任何地方创建副本... - tpeczek