📜  浅拷贝与深拷贝 c# 代码示例

📅  最后修改于: 2022-03-11 14:49:10.430000             🧑  作者: Mango

代码示例1
// Shallow Copy
A ob1 = new A();
ob1.a = 10;
A ob2 = new A();
ob2 = ob1;
ob1.a = 5; // <-- If you see value of ob2.a after this line, it will be 5

// Deep Copy
A ob1 = new A();
ob1.a = 10;
A ob2 = new A();
ob2.a = ob1.a;
ob1.a = 5; // <-- If you see value of ob2.a after this line, it will be 10.