C# 数组深拷贝浅拷贝
1 bool[] tmp1 = { true, true }; 2 bool[] tmp2; 3 4 //tmp2 = tmp1; //浅拷贝 更改tmp2 会影响tmp1 5 6 tmp2 = (bool[])tmp1.Clone(); //克隆深拷贝 更改tmp2 不会影响tmp1 7 8 tmp2[0] = false; 9 tmp2[1] = false; 10 11 foreach (bool flag in tmp1) 12 { 13 Console.Write(flag); 14 Console.Write(" "); 15 } 16 Console.WriteLine();