C# 中的浅表副本与深表副本
public class Student { public int age; public Student(int age) { this.age = age; } } public class Grade { public int gradeIndex; public Student stu; public Grade(Grade grade) { gradeIndex = grade.gradeIndex; } //浅表副本 public Grade WiseCopy() { return (Grade)this.MemberwiseClone(); } //深表副本 public Grade DeepCopy() { Grade grade = (Grade)this.MemberwiseClone(); grade.stu = new Student(this.stu.age); return grade; } }