First:
首先实现ICloneable接口
public class Test : ICloneable
Second:
实现Clone方法
public object Clone()
{
//下面方法选其一(需要了解区别)
//浅拷贝-->值类型的copy,其他仍是copy的引用
return this.MemberwiseClone();
//深拷贝--->new一个对象,完全的值拷贝
return new Test() as object;
}
Third:
用Clone方法实现克隆
Test test新对象 = (Test)test旧对象.Clone();
PS:犹豫Clone返回的是Object,所有要强行转换类型