我的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";
Run Code Online (Sandbox Code Playgroud)
所以现在我希望MyPrimaryList中第一个数组中的第一个值在MySecondaryList中是"onehalf"和"one".但我的问题是两个列表都更新为"onehalf"作为两个列表中第一个数组的第一个值.
你有一个很好的解释吗?:)
谢谢!!