List<Box[]> boxesList = new List<Box[]>(); // create a new list that contains boxes
Box[] boxes = new Box[9]; // create an array of boxes
boxesList.Add(boxes); // add the boxes to the list
boxesList[0][0] = new Box(2, new Point(0, 0)); // change the content of the list
boxes[0] = new Box(1,new Point(0,0)); // change content of the boxarray
问题是初始化框阵列的第一 元件之后改变。 boxesList也被改变。 我认为问题在于 数组在列表中存储为引用。 有没有办法解决这个问题? 从而使boxeslist不会通过改变框阵列C#防止作出列出
所以你想要在列表中存储数组的克隆,而不是原始数组?这是你的问题吗? –